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())+"',//此处中含有空值,我想问问有没有什么方法可以判断一下如果是空值则数据库里存空值,如果有和转化为decimal存到数据库中
(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() + "')";
+ 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())+"',//此处中含有空值,我想问问有没有什么方法可以判断一下如果是空值则数据库里存空值,如果有和转化为decimal存到数据库中
(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() + "')";
-->
先做空置判断,String x;
x=(objDS.Tables[0].Rows[i][8]!=System.DBNull.Value?objDS.Tables[0].Rows[i][8].ToString():"null");然后把x拼接到sql1中.
就判objDS.Tables[0].Rows[i][8] == null,是就拼个NULL进去,不是就转换objDS.Tables[0].Rows[i][8]
string f = string.Empty;
if (e !=null )
{
f= Convert.ToDecimal(objDS.Tables[0].Rows[i][8].ToString());//此处报错,错误1无法将类型“decimal”隐式转换为“string”
}
else
{
}
这咋整啊?拜托了
请参考2楼写法.