多之前向sql2000里面插入数据,正常插入,但现在因为空间要求要换成access的,我把原来的sql语句放进vs2003,为何会提示出错呢?原来的语句
INSERT INTO customer
      (type, name, tel, area, address, kind, datetime, content)
VALUES (@type, @name, @tel, @area, @address, @kind, @datetime, @content)为什么数据库变为access后会出错呢?提示的是这条语句错,请大家帮帮忙啊

解决方案 »

  1.   

    同样是customer表,里面的字段都是一样的,请大家帮忙啊,要不我就被老板骂了
      

  2.   

    DateTime is a reserved word, try to escape itINSERT INTO customer
          (type, name, tel, area, address, kind, [datetime], content)
    VALUES (@type, @name, @tel, @area, @address, @kind, @datetime, @content)also, make sure the order of adding parameters is same as in the sql
      

  3.   

    access的参数中好象没有@标记吧?
      

  4.   

    INSERT INTO customer
          (type, name, tel, area, address, kind, datetime, content)
    VALUES (@type, @name, @tel, @area, @address, @kind, @datetime, @content)
    这是应为
    INSERT INTO customer
          (type, [name], [tel], [area], [address], [kind], [datetime], [content])
    VALUES (@type, @name, @tel, @area, @address, @kind, @datetime, @content)
      

  5.   

    楼主用了Sql关键字,比如type,datetime所以要加[]以和sql关键字区分开来.
    还有,看一下Access的字段是否有约束规则导致数据不能插入.
      

  6.   

    楼主
    DateTime在Access和sql下是不一样的
    写两个查询语句就知道了
      

  7.   

    我也遇到了此类问题,我的ACCESS数据库连接字符串写在了web.config文件中
    <appSettings>                       
    <add key="SQLCON" value="Provider=Microsoft.Jet.OLEDB.4.0;Data Source='D:\TaLangProgram\JXProgram\DATA\JX.mdb'"/>
    </appSettings>
    数据库可以打开,但在执行插入的时候无法运行,不知道是怎么回事,问了下网上的朋友说是权限问题,可是如果是权限问题的话应该无法打开数据库的吧?
    求各位大虾指教!!!
      

  8.   

    晕死,Access里根本就没有存储过程,你那样写有什么用,先把要执行的sql语句串成一个字符串,然后再执行,你加了参数,当然不行了.