I got the code like this:
DataSet quantity DDS = zero; . . . Quantity DDS = GetAllUPCDSDRecords (txtUPC.Text); ... which is blowing with "Table 0 can not be found"
To try to stop it, I try any of the following Has not;
1)
if (empty! For quantity) 2)
String table 0 = volumeDisciples Tables [0]. Ostring (); If (! Table0.Equals (string.Empty)) 3)
if (zero! = QtyDS.Tables [0]) How can I safely determine the query is returning a dataset or not so as to avoid error messages?
update public dataset getAllUPCDSDRecords (string UPC) {string query = String.Format ("Tiger, UPC as upc_source, description as descrip, unit_qty volume Select tyger_id as, "+" in the form of department, as the Wayne, as UPCPK, PKSize, as pack_size VENDOR_ID upc_pack_size "+" Uniciocost as the CCT, the form of list In Unit_Lite "+" FOA {0} where your_source = {1} ", tablename, upscale); 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); } Hold {//SSCS.ExceptionHandler (ex, "DBConnection.getDataSet"); } Return (ODS); } // getDataSet
It seems that you are swallowing and ignoring your error Your code is going fine when you do not have it.
You can remove the comment
public dataset getDataSet (string dynSQL) {checkConnection (). SqlCeDataAdapter ODA = New SqlCeDataAdapter (dynSQL, objCon); Dataset ods = new dataset ("command"); Try {ODA.Fill (ods); } Hold (Exception Pre) {Console.WriteLine (ex.Message); } Return (ODS); } To see just the error, enter a break point at Console.WriteLine . After this is fixed, you try to catch the entire ... catch up routine so that if something goes wrong, then it is not hidden from you. To make it one step further, change the signature and put a check on checkConnection method: public dataset getDataSet ( String dynSQL) {var ODS = new datasets ("command"); Try {if (CheckConnection ()) {new exception ("no connection to database."); } (Var Oda = New SQL Account (dynSQL, objCon)) {ODFIL (ODS); }} Hold (Exception Pre) {Console.WriteLine (ex.Message); } Return (ODS); }
No comments:
Post a Comment