sbornstein2
asked on
Checking for a null recordset return - C# - SQL
Hello all. I need to run a check if I return a record from a table based on criteria. Then I need to say if not rs.EOF etc. How do I handle that in C#? Thanks all
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
There are datasets and there are datatables.
Datasets can contain DataTables or DataTables can be stand alone.
you can check to see if a datatable is empty like this.
DataTable dtDataTable = new DataTable("dtDataTable");
dtDataTable = ###Some code to fill the table with data.###
//To check for NULL
if (dtDataTable == null)
{
//code
}
//To check for NOT NULL
if (!(dtDataTable == null)) // or (dtDataTable != null)
{
//code
}
//To check for empty table
if (dtDataTable.Rows.Count > 0)
{
//code
}
//To scroll through table until EOF
foreach (DataRow drDataRow in dtDataTable.Rows)
{
MessageBox.Show(this, drDataRow["ColumnName"].To
//code
}
If a dataset is used just replace 'dtDataTable' with 'dsDataSet.Tables["dtDataT
I think thats it.
Hope I helped alittle.