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();
}
}
}


Manas MohapatraRank #182 · 13.2K reputationPosted Sep 25, 2015, 3:11 AM EDT
Sujeet SumanRank #790 · 2.9K reputationPosted Sep 25, 2015, 9:42 AM EDT
सौरभ माहेश्वरीRank #6,639 · 260 reputationPosted Sep 25, 2015, 9:48 AM EDT
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 SumanRank #790 · 2.9K reputationPosted Sep 25, 2015, 9:59 AM EDT
com.CommandText = sam2;
सौरभ माहेश्वरीRank #6,639 · 260 reputationPosted Sep 25, 2015, 10:05 AM EDT
Sujeet SumanRank #790 · 2.9K reputationPosted Sep 25, 2015, 10:06 AM EDT
Sujeet SumanRank #790 · 2.9K reputationPosted Sep 25, 2015, 10:09 AM EDT