使用TSQLQuery和params捕获异常(Trapping Exception using TSQLQuery & params)
我收到“SQL Server错误:算术异常,数字溢出或字符串截断”错误
这是下面的代码
AQuery:= TSQLQuery.Create(nil); with AQuery do begin SQLConnection:- AConnection; SQL.Text:= 'Insert into.....'; ParamByName('...').asString:= 'PCT'; . . . try ExecSQL; finally AQuery.Free; end; end;我有很多ParamByName行,我无法弄清楚哪一行抛出异常。 我只知道它在ExecSQL系列上的抛出。 我怎么知道哪个paramByName导致错误?
I am getting a "SQL Server Error: arithmetic exception, numeric overflow, or string truncation" error
here is the code below
AQuery:= TSQLQuery.Create(nil); with AQuery do begin SQLConnection:- AConnection; SQL.Text:= 'Insert into.....'; ParamByName('...').asString:= 'PCT'; . . . try ExecSQL; finally AQuery.Free; end; end;I have alot of ParamByName lines, and I can't figure out which one is throwing the exception. I just know its thrown on the ExecSQL line. How can i tell which paramByName is causing the error?
最满意答案
您正在尝试将字符串值插入到不足以容纳该值的字段中。 根据表中字段的长度检查要插入的值的长度。
You are trying to insert a string value into a field that is not big enough to hold the value. Check the length of the values you are inserting against the length of the field in the table.
更多推荐
发布评论