http://www.wzjcw.net/vbgood/taishan/index.html

解决方案 »

  1.   

    Const sBiao As String = ","
    这是源代码:
    Const sYing As String = """"
    strSql = "insert into 进退货明细表 (单号,日期,进货单位,货号,价格,数量,金额) values ("
    strSql = strSql & sYing & sNumber & sYing + sBiao + sYing & Date$
    strSql = strSql & sYing + sBiao + sYing & Combo1.Text & sYing + sBiao + sYing & ListView.ListItems(1).Text
    strSql = strSql & sYing + sBiao & CSng(Mid(sPrice, 2, Len(sPrice)))
    strSql = strSql & sBiao & iNum & sBiao & cMon & ")"
    这是执行后strSQL的结果:
    insert into 进退货明细表 (单号,日期,进货单位,货号,价格,数量,金额) values ("00000000006","2002-02-05","杜金波","120098",60,-12,-720)
      

  2.   

    conn.mode改了还是不行,是不是在SQL代码中使用VB的变量有什么限制?
      

  3.   

    还有一种可能,你的ADO版本过低。
    The information in this article applies to:ActiveX Data Objects (ADO), versions 1.5, 2.5--------------------------------------------------------------------------------
    SYMPTOMS
    Receiving error 3001 using an ADODB.Recordset when the filter string contains '*stringvalue' pattern for the string column even if the operator is '='. CAUSE
    The application is using arguments that are of the wrong type, are out of acceptable range, or are in conflict with one another. STATUS
    This bug was corrected in ActiveX Data Objects (ADO) version 2.0.MORE INFORMATION
    Put_Filter fails if the filter string contains '*stringvalue' pattern for the string column even if the operator is an '='. It should not fail. It acts like the LIKE syntax. Steps to Reproduce Behavior   Sub FilterEqualFails()
           Dim conn As New ADODB.Connection
           Dim rs As New ADODB.Recordset       conn.Open "<DSN_Name>", "sa", ""
           On Error Resume Next
           conn.Execute "drop table Test"
            On Error GoTo errh
           conn.Execute "create table Test(id int primary key,f1 " & _
                        "varchar(200)"
           rs.Open "select * from Test", conn, adOpenKeyset, adLockOptimistic
           rs.AddNew
           rs("id") = 1
           rs("f1") = "*x Hello world"
           rs.Update
           rs.Requery
           rs.Filter = "f1 = '*x Hello world'"
           Exit Sub   errh:       Debug.Print "Error:", Err, Hex(Err)
           Debug.Print "Source:", Err.Source
           Debug.Print "Desc:", Err.Description   End Sub 
    When you execute this code, you expect it to find the row with the value. However, this is the output received when you execute the code:    Error:        3001         BB9
       Source:       ADODB.Recordset 
      

  4.   

    SQL语句应该是这样的:
    insert into 进退货明细表 (单号,日期,进货单位,货号,价格,数量,金额) values ('00000000006','2002-02-05','杜金波','120098',60,-12,-720) 
      

  5.   

    数据类型不对:
    MORE INFORMATIONSteps to Reproduce
    In Microsoft Visual Basic 5.0 or 6.0, open a new Standard EXE project. Form1 is created by default. 
    On the Project menu, select References, and add a reference to Microsoft ActiveX Data Objects 2.1.
    Place the following code in the Form1 Code module:Private Sub Form_Load()
    Dim rs As New ADODB.Recordset
    Dim cn As New ADODB.ConnectionWith cn
    .ConnectionString = "PROVIDER=Microsoft Jet 3.51 OLE DB Provider;DATA SOURCE=" & App.Path & "\Biblio.MDB"
    .Open
    End Withcn.Execute "update authors set author = 'Carsons''' where au_id = 1"
    'cn.Execute "update employees set 'Last Name' = 'Carsons' where 'Employee ID' = 1" 
    With rs
    .CursorLocation = adUseClient
    .LockType = adLockBatchOptimistic
    .CursorType = adOpenStatic
    .ActiveConnection = cn
    .Open "select * from authors"
    End Withrs.Filter = "author = 'Carsons'''"
    Debug.Print rs.RecordCount
    Debug.Print rs(1)cn.Execute "update authors set author = 'Car''sons''' where au_id = 1"rs.Filter = "author = 'C''arsons''" 'Error Occurs Here
    Debug.Print rs.RecordCount
    Debug.Print rs(1)End Sub 
    NOTE: You might have to adjust the path to BIBLIO.MDB.
    Run the project.Results:
    Run-time Error '3001' Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another.&copy; Microsoft Corporation 2000, All Rights Reserved.
    Contributions by Terrell D. Andrews, Microsoft Corporation&copy; Microsoft Corporation 2000, All Rights Reserved.
    Contributions by Matthew Hofacker, Microsoft Corporation
      

  6.   

    字符变量应用''而不是"",时间用''或cdate('2002-02-05'')形式,转换函数cdate在不同数据库里是不一样的。SqlServer里是cast(),Access 是cdate(),foxpro里是date(),to_date()