SqlConnection con = new SqlConnection(cnstr);
SqlCommand cmd = new SqlCommand(sqlStmt, con);
SqlDataAdapter da = new SqlDataAdapter(cmd);
try {
cmd.Connection.Open();
rows = cmd.ExecuteNonQuery();
if (rows == -1) {
Response.Write("No Rows returned from query");
Response.End();
}
Message + "\n" + "LineNumber: " + ex.Errors[i].LineNumber + "\n" + "Source: " + ex.Errors[i].Source + "\n" + "Procedure: " + ex.Errors[i].Procedure + "\n"); } Response.Write(errorMessages.ToString()); }
Sam HobbsPosted Oct 26, 2010, 6:07 PM
When I ask a question, I am happy to get help locating the documentation or article that has the answer.
I think the one that is quibbling is the one that refuses to do what they are asked to do before requesting assistance.
Lyle GriessPosted Oct 26, 2010, 4:54 PM
Sam HobbsPosted Oct 26, 2010, 4:51 PM
Look at the documentation again; it is extremely clear why the return value from ExecuteNonQuery is "always -1 for select statements". If you already knew that then posting the sample code was useless; you should have asked how to do what you need to do.
Lyle GriessPosted Oct 26, 2010, 1:01 PM
cmd.Connection.Open();
rows = cmd.ExecuteNonQuery();
if (rows == -1) {
Response.Write("No Rows returned from query");
Response.End();
and viewing the doc on this command does not show how to do it.
the sqlStmt that gets passed is a dynamic select statement.
rows passed back from this is the "rows affected" and is always -1 for select statements.
Sam HobbsPosted Oct 25, 2010, 11:36 PM
Lyle GriessPosted Oct 25, 2010, 11:16 AM
Suthish NairPosted Oct 25, 2010, 4:06 AM
Suthish NairPosted Oct 22, 2010, 1:50 AM