我试图将FoxPro中的表格变成C#
。我使用以下声明;
sqlCmd.CommandText = @"SELECT ew.ew_pplid, ew.ew_name, ew.ew_from, ew_to, ew.ew_totdays
FROM empwork ew
INNER JOIN employs emp ON ew.ew_pplid = emp.em_pplid
WHERE emp.em_netname NOT LIKE ''
AND TRIM(emp.em_netname) <> ''
AND emp.em_type <> 2
AND ew.ew_from > ?";
sqlCmd.Parameters.AddWithValue("pDate", Convert.ToDateTime("01/08/2016"));
但是我收到了一个我从未见过的错误;
The Provider could not determine the Decimal value. For example, the row was just created, the default for the Decimal column was not available, and the consumer had not yet set a new Decimal value.
之前有没有人看过这个错误,如果有的话,我怎么能绕过这个呢?
答案 0 :(得分:1)
如果在日期时间因为虚假信息而窒息,您可以通过
稍作修改来尝试 AND ew.ew_from > CTOD( ? )";
并将参数作为日期
的字符串sqlCmd.Parameters.AddWithValue("pDate", "01/08/2016");
VFP的命令CTOD()表示字符到日期,并且由于您已经处于预期的月/日/年格式,因此应该通过。
如果失败实际上是在另一个字段上,例如&#34; ew.ew_totdays&#34;,您可以始终通过更新查询来限制返回的字段只是一个ID键,单独留下where子句。然后,如果它通过,一次添加一个字段。您可能在数据中的某处有一个NULL值。
如果所有字段都正常,那么您可能必须根据WHERE子句应用查询并一次剥离一个部分的条件,直到所有字段都被应用为止。