Lyle Griess

Lyle Griess

  • NA
  • 13
  • 37.9k

How do I trap zero rows returned from sql statement c#

Oct 21 2010 6:15 PM

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


Answers (8)