Hi I want to store query result in single variable like
if query is "select count(*) from tablename" , and it return suppose 21 records (integer value) then I want to save this value in my database during insertion of record
what should i write in place of question mark sign in below code...
string qry;
qry = "insert into General values(@Gno,@GRno,@Fname,@Mname,@Lname,@Sex,@Bdate,@Pass,@Mono,@OtherNo,@Photo,@Role,@GCID)";
SqlCommand cmd = new SqlCommand(qry, cn);
cmd.Parameters.AddWithValue("@Gno",??????????? );
cmd.Parameters.AddWithValue("@GRno", TxtAddress.Text);
cmd.Parameters.AddWithValue("@Fname", RadioButtonList1.SelectedItem.Text);
cmd.Parameters.AddWithValue("@Mname", DrpDwnDD.SelectedItem.Text);
cmd.Parameters.AddWithValue("@Lname", DrpDwnMM.SelectedItem.Text);
cmd.Parameters.AddWithValue("@Sex", DrpDwnYY.SelectedItem.Text);
cmd.Parameters.AddWithValue("@Bdate", TxtUserName.Text);
cmd.Parameters.AddWithValue("@Pass", TxtPassword.Text);
cmd.Parameters.AddWithValue("@Mono", TxtEmail.Text);
cmd.Parameters.AddWithValue("@OtherNo", DrpDwnCountry.SelectedItem.Text);
cmd.Parameters.AddWithValue("@Photo", "~/Photo/" + FileUpload1.FileName);
cmd.Parameters.AddWithValue("@Role", DroDpwnPerque.SelectedItem.Text);
cmd.Parameters.AddWithValue("@GCID", TxtAns.Text);
FileUpload1.SaveAs(Server.MapPath("~/Photo/" + FileUpload1.FileName));
cmd.ExecuteNonQuery();
Please Help Me..................