daimous
Sep 17th, 2006, 09:34 PM
hi guys! i have a code below that query something from my database
string SqlConnStr = Properties.Settings.Default.MyConnString;
sqlConn = new SqlConnection(SqlConnStr);
sqlConn.Open();
string qryStr = "Select Max(number) from docs_ref";
SqlCommand SqlCmd = new SqlCommand(qryStr, sqlConn);
object result = SqlCmd.ExecuteScalar();
SqlCmd.Connection.Close();
sqlConn.Close();
but how can I check if it does return any value or not and if it does how can i retrieve the value? thanks.
string SqlConnStr = Properties.Settings.Default.MyConnString;
sqlConn = new SqlConnection(SqlConnStr);
sqlConn.Open();
string qryStr = "Select Max(number) from docs_ref";
SqlCommand SqlCmd = new SqlCommand(qryStr, sqlConn);
object result = SqlCmd.ExecuteScalar();
SqlCmd.Connection.Close();
sqlConn.Close();
but how can I check if it does return any value or not and if it does how can i retrieve the value? thanks.