The first MessageBox.Show() below simply shows me the exact same thing as const string SQL_GET_VENDOR_ITEMS, which seems fine to me, but I'm getting, "There was an error parsing the query. [Token line number, Token line offset,, Token in error,,]"
Is there a way to spy on the contents of the SQL after parameters have been added; it should then be something like: "SELECT ItemID, PackSize FROM VendorItems WHERE VendorID = 'TEST' AND VendorItemID = '852963'
Here's the pertinent code:
const string SQL_GET_VENDOR_ITEMS = "SELECT ItemID, PackSize " +
"FROM VendorItems " +
"WHERE VendorID = @VendorID AND VendorItemID = @VendorItemID";
string retVal = string.Empty;
checkConnection();
SqlCeCommand vendorCMD = objCon.CreateCommand();
try
{
vendorCMD.CommandText = SQL_GET_VENDOR_ITEMS;
vendorCMD.Parameters.Add("@VendorID", SqlDbType.NVarChar, 10).Value = VendorID;
vendorCMD.Parameters.Add("@VendorItemID", SqlDbType.NVarChar, 19).Value = VendorItemID;
MessageBox.Show(string.Format("Made it up to vendorCMD.ExecuteReader() with sql {0}", vendorCMD.CommandText));
. . .
vendorReader.Close();
}
catch (SqlCeException sqlceex)
{
MessageBox.Show(string.Format("SqlCeException in GetValsForVendorAndItem == {0}", sqlceex.Message));//TODO: Remove
}
finally
{
vendorCMD.Dispose();
}
return retVal;
. . .