In this code when i run this 2 query is execute but 1st query is not excute .here 1st query come from a text box and 2nd written by me but if i pass query direct then it work and if i give in this type then its not work ...
else
{Session["DB"] = DropDownList4.SelectedItem.Text;
string sam =word0 + " " + word1 + " " + word2 + " " + abc + "='" + abc4 + "' " + word4 + " " + abc2 + "='" + abc5 + "'";
string sam2 = "insert into testing values(12,'sasasas')";
SqlConnection con = new SqlConnection("Data Source=server;Initial Catalog='" + Session["DB"]+ "';Persist Security Info=True;User ID=sa;Password=password");
SqlCommand com = new SqlCommand();
com.Connection = con;
com.CommandText = sam;
com.CommandText = sam2;
com.CommandType = CommandType.Text;
try
{
con.Open();
com.ExecuteNonQuery();
}
catch (SqlException sa)
{
Response.Write(sa.Message);
}
finally {
con.Close();
}
}
}

Sujeet SumanPosted Sep 25, 2015, 2:09 PM
Sujeet SumanPosted Sep 25, 2015, 2:06 PM
सौरभ माहेश्वरीPosted Sep 25, 2015, 2:05 PM
Sujeet SumanPosted Sep 25, 2015, 1:59 PM
com.CommandText = sam2;
सौरभ माहेश्वरीPosted Sep 25, 2015, 1:48 PM
In Sam the query is update testing set name='sam' where id=1;
Now according to query every word have split and store in word[] array ...but when I debug the code that time sam2 query execute but sam query is not execute ..why I am not under...please tell .
Sujeet SumanPosted Sep 25, 2015, 1:42 PM
Manas MohapatraPosted Sep 25, 2015, 7:11 AM