日期:2014-05-16  浏览次数:20618 次

输入字符串的格式不正确(说是有字符串不能转换成Datetime,但是我这里只有sys_create_date和sys_modify_date是datetime)
string sql1 ="insert into tb_product(id,sys_create_stuff,sys_create_date,sys_modify_stuff,sys_modify_date,sys_delete_flag,sys_remote,ASACode,WordCode_1,WordCode_2,WordCode_3,WordCode_4,BrandColor,WordPrice,Origin,Material,Brand,ProductName)values(NEWID(),'9E3941AE-84F3-4983-940E-0F36B609CB4B',GETDATE(),'9E3941AE-84F3-4983-940E-0F36B609CB4B',GETDATE(),'0','0','" 
                     + objDS.Tables[0].Rows[i][2].ToString() + "', '" + a + "' ,'" + b + "','" + c + "','" + d + 
                     "',(select id from tb_product where BrandColor=(select id from zl_color where colorName='" 
                     + objDS.Tables[0].Rows[i][7].ToString() + "')),
 '"+Convert.ToDecimal(objDS.Tables[0].Rows[i][8].ToString().Trim())+"',//还是不行啊!此处是报错处
(select id from tb_product where Origin=(select id from zl_country where Name='"
                     + objDS.Tables[0].Rows[i][10].ToString() + "')),(select id from tb_product where Material=(select id from zl_material where MaterialName= '" 
                     + objDS.Tables[0].Rows[i][11].ToString() + "')),(select id from tb_product where Brand=(select id from zl_brand where BrandName='" 
                     + objDS.Tables[0].Rows[i][5].ToString() + "')),'" + objDS.Tables[0].Rows[i][4].ToString() + "')"; 
输入字符串的格式不正确(说是有字符串不能转换成Datetime,但是我这里只有sys_create_date和sys_modify_date是datetime是datetime类型的,这两个的Values赋的值用的是GETDATE(),难道不对么?或者别的地方有误?求解)
------解决方案--------------------
建议用SQL Profiler工具跟踪所执行的TSQL语句,
可能是目标表字段列表与值列表对应有误.
------解决方案--------------------
调式中快速监视一下:objDS.Tables[0].Rows[i][8].ToString().Trim()看看得到什么值。