有点看不懂啊,她提示你insert into语句语法错误了啊。肯定问题就出在insert into这里,你仔细检查一下,看看数据类型是不是匹配。

解决方案 »

  1.   

    总算找到原因了,不知道怎么回事:我的代码比你多了个异常处理就好了,没有异常处理,我的也回抛出异常。
    string source="server=sim;uid=sa;pwd=;database=demo";
    SqlConnection conn=new SqlConnection(source);
    conn.Open();
    try
    {
    string bh="01010101";
    string xm="smsms";
    string select ="insert into tbl_charge_account2004 (bh,xm) values('"+bh+"','"+xm+"')";
    Console.WriteLine(select);
    //string select="select mzfph,xm from tbl_charge_account2004 order by mzfph for xml auto";
    SqlCommand cmd=new SqlCommand(select,conn);
    cmd.ExecuteNonQuery();
    }
    catch(Exception e){

    }
    conn.Close();
      

  2.   

    你可以跟踪到ExcuteNoneQuery这一句,看看Command的CommandTExt是不是正确的Sql语句