Dim now As Date
  now = Date
  conn.Execute "insert into LendTable(DocId,Quantity,User,Date) values_
              (" & CInt(Id) & "," & CInt(Quantity) & ",'" & Borrower_ 
                & "'," & now & ")"
  应该是这样!?

解决方案 »

  1.   

    conn.Execute "insert into LendTable(DocId,Quantity,User,Date) values 
      (" & CStr(CInt(Id)) & "," & CStr(CInt(Quantity)) & ",'" & Borrower & "','" & Format(now,"mmmm dd yyyy" & "')"
    时间型的数据要先转化
      
      

  2.   

    now 是系统内部命令,所以冲突了.
    换个变量就可以了,比如 Today.
      

  3.   

    如果你的数据库是ACCESS 请用INSERT INTO
    如果你的数据库是SQL    请用INSERT 
      

  4.   

    conn.Execute "insert into LendTable(DocId,Quantity,User,Date) values 
      (" & CStr(CInt(Id)) & "," & CStr(CInt(Quantity)) & ",'" & Borrower & "',#" & now & "#)"
      

  5.   

    conn.Execute "insert into LendTable(DocId,Quantity,User,Date) values 
      (" & CInt(Id) & "," & CInt(Quantity) & ",'" & Borrower & "',#" & Format(now,"yyyy/mm/dd) & "#)"
     
      

  6.   

    对不起,错了一点
    conn.Execute "insert into LendTable(DocId,Quantity,User,Date) values 
      (" & CInt(Id) & "," & CInt(Quantity) & ",'" & Borrower & "',#" & Format(now,"yyyy/mm/dd") & "#)" 
      

  7.   

    now 是系统变量,不能自己再定义的
      

  8.   

    User,Date 可能为系统保留字
    用括号括起来 或 改用别的字段名 
      

  9.   

    把sql语句debug.print出来给大家瞧瞧
      

  10.   

      Dim mynow As Date
      mynow = Date
      conn.Execute "insert into LendTable(DocId,Quantity,User,Date) values 
                  (" & CInt(Id) & "," & CInt(Quantity) & ",'" & Borrower 
                    & "','" & mynow & "')"
      
      

  11.   

    我的做法:
      Dim now As Date
      now = Date
      conn.Execute "insert into LendTable(DocId,Quantity,User,Date) values 
                  ('" & CInt(Id) & "','" & CInt(Quantity) & "','" & Borrower 
                    & "','" & now & "')"
      
      

  12.   

    1。now是内部函数
    2。时间格式应用#符号
      

  13.   

    to qaymuic(qaymuic) 
    "2。时间格式应用#符号  "
    你试试  #2001-10-1# 看会不会报错
      

  14.   

    haitaoyu(i老虎u) 
    如果这种问题的话不会报错!只会返回空纪录集!
      

  15.   

    不要用USER﹐USER是SQL保留字   
      

  16.   

    哇,我终于找到答案拉!!!!!!!!!!!!!!!!!!!
    谢谢大家,特别是  T2(無藥可救) 先生、haitaoyu(i老虎u)等。
    事情是这样的:
        1.  不能用 User,因为 User 是sql的保留字;
        2.  不能用Date,因为 Date 是Vb的保留字。
    以后大家一起注意下不要用保留字啊~~~~~~~~~~~~~要不就会像我这样惨!
    谢谢大家的支持。