I've got code like this:
DataSet QtyDS = null;
. . .
QtyDS = GetAllUPCDSDRecords(txtUPC.Text);
...that is blowing up with "cannot find table 0"
To try to prevent that, I've tried the following, all to no avail; I still get that err msg when I try to access the first table in the Dataset:
1)
if (null != QtyDS)
2)
string table0 = QtyDS.Tables[0].ToString();
if (!table0.Equals(string.Empty))
3)
if (null != QtyDS.Tables[0])
How can I safely determine whether the query is returning a dataset so as to avoid the err msg?
UPDATE
public DataSet getAllUPCDSDRecords(string upc)
{
string query = string.Format(
"SELECT tyger_id as tyger, upc_source as UPC, description as Descrip, unit_qty as Qty, "+
"department as Dept, vendor_id as Ven, upc_pack_size as UPCPK, pack_size as PKSize, "+
"unit_cost as Cst, unit_list as Lst "+
"FROM {0} WHERE upc_source = {1}", tablename, upc);
return dbconn.getDataSet(query);
}
public DataSet getDataSet( string dynSQL )
{
checkConnection();
SqlCeDataAdapter oDA = new SqlCeDataAdapter( dynSQL, objCon );
DataSet oDS = new DataSet( "Command" );
try
{
oDA.Fill( oDS );
}
catch
{
//SSCS.ExceptionHandler(ex, "DBConnection.getDataSet");
}
return( oDS );
} // getDataSet