I use ADO and new to C#.
This source shows records have been read whether successful or not. Works well if record/s found, never shows MessageBox.Show("No Records")
public static void readSqlData(String sSource)
{
string strSelection = "SELECT * FROM " + sSource;
SqlDataAdapter da = new SqlDataAdapter(strSelection, cnn);
if (da != null)
{
MessageBox.Show("Records have been read");
dt = new DataTable();
da.Fill(dt);
}
else
{
MessageBox.Show("No records \n" + strSelection);
}
}
I have searched for "Test if SqlDataAdapter is empty". I don't understand the answers. Sorry, to easily confused.
Check whether datatable rows count higher from zero or not.
public static void readSqlData(String sSource)
{
string strSelection = "SELECT * FROM " + sSource;
SqlDataAdapter da = new SqlDataAdapter(strSelection, cnn);
DataTable dt = new DataTable();
da.Fill(dt);
if (dt.Rows.Count > 0)
{
MessageBox.Show("Records have been read");
}
else
{
MessageBox.Show("No records \n" + strSelection);
}
}