开发者

How can I isolate which parameter is throwing error in Insert Method?

I'm passing parameters (over 30 in all) from a system.data.dataset into a tableadapter insert method, but I'm getting an "Input string was not in a correct format" exception.

The error points to the method that is throwing, which is great, but is there a way I can tell exactly which parameter is throwing the error?

(Sorry about the code formatting -- I fought with it for 5 minutes before giving up)开发者_高级运维

myTableAdapter.Insert( 
    row["GUID"].ToString(),
    Convert.ToInt16(row["domain"].ToString()),
    Convert.ToInt16(row["plan"].ToString()),
    Convert.ToInt16(row["type"].ToString()),
    Convert.ToInt16(row["type_alt"].ToString()), ...etc

Thanks in advance!


Create a bunch of Int16 variables, convert into them, then pass to the Insert() method

Int16 domain = Convert.ToInt16(row["domain"].ToString());
Int16 plan = Convert.ToInt16(row["plan"].ToString());

..etc..

myTableAdapter.Insert( 
    row["GUID"].ToString(),
    domain,
    plan,

..etc..

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜