my code is i wana write another select statment in this button but i am confuse where....plz help
protected void Button4_Click(object sender, EventArgs e)
{
if (rankuserid.Text.Length == 0)
{
Response.Write("");
}
else
{
con.Open();
SqlCommand cmd = new SqlCommand("select * from salesmans_master where rankuser=" + rankuserid.Text);
cmd.Connection = con;
SqlDataReader dr = cmd.ExecuteReader();
if (dr.Read())
{
rankcode.Text = dr["rankcode"].ToString();
be.Text = dr["rank1"].ToString();
srbe.Text = dr["rank2"].ToString();
fdo.Text = dr["rank3"].ToString();
fi.Text = dr["rank4"].ToString();
srfi.Text = dr["rank5"].ToString();
doff.Text = dr["rank6"].ToString();
zo.Text = dr["rank7"].ToString();
po.Text = dr["rank8"].ToString();
pog.Text = dr["rank9"].ToString();
bd.Text = dr["rank10"].ToString();
con.Close();
}
}
4 Replies
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Amit GuptaPosted Mar 27, 2016, 3:38 PM
Yes.. you can use procedure as suggested by Mr. Vishal.. it will be faster than you execute a query.. or if you dont want to use procedure.. you can use multiple query as shown below.
String query = "select * from table1 ; select * from table2";
var adp= new SqlDataAdapter (query, connectionstring);
DataSet ds= mew DataSet ();
adp.Fill (ds);
// when the above query got executed... it fetch your data in 2 different tables.. i.e
var first= ds.Tables [0];
var second = ds.Tables [1];
Rest... as per your requirement.
Vishal JadhavPosted Mar 25, 2016, 7:00 AM
Sakthikumar ThanavelPosted Mar 25, 2016, 2:08 AM
Saillesh PawarPosted Mar 25, 2016, 1:49 AM