Check the Table is Empty
Using Oledb
Step 1: Establishing Connection
OleDbConnection OCon=new OleDbConnection(StrCon);
//StrCon is a connection String
Step 2: Check Whether the Table is Empty
OCon.Open();
OleDbCommand OCmd = new OleDbCommand(StrQry, OCon); OleDbDataReader Rdr=OCmd.ExecuteReader();
if (Rdr.HasRows)
message(“table is not Empty”);
else
message(“table is Empty”);
Using Sqlclient
Step 1: Establishing Connection
SqlConnection OCon=new SqlConnection (StrCon);
//StrCon is a connection String
Step 2: Check Whether the Table is Empty
OCon.Open();
SqlCommand OCmd = new SqlCommand(StrQry, OCon);
SqlDataReader Rdr=OCmd.ExecuteReader();
if (Rdr.HasRows)
message(“table is not Empty”);
else
message(“table is Empty”);
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home