none
Multi Step OLEDB ERROR RRS feed

  • Question

  • Hello friends i am using VBA editor want to insert value into sql database....Can Anybody tell me which sql refences are added for MS Sql server 2008 R2...because My code is.....and i am facing error Multistep OLEDB operation generated errors.

    Check each OLEDB status value..Help me.

    Sub Adddata()
    Dim con As ADODB.Connection
    Dim rs As ADODB.Recordset
    'Dim constring As ConnectionString
    Set con = New ADODB.Connection
    Dim cmd As ADODB.Command
    con.ConnectionString = "Data Source=ADMIN-PC;Initial Catalog=AD-PC;Integrated Security=SSPI"
    'On Error Resume Next
    con.Open
    cmd.CommandText = "insert into first values '" + numvalue1 + "','" + numvalue2 + "'"
    cmd.Execute
    con.Close
    End Sub

    Please help me....
    Tuesday, December 23, 2014 7:01 AM

All replies

  • Hello,

    I can't see a new instance of your ADODB.command object.

    Dim cmd As  NEW ADODB.Command  (new is missing).

    On the other hand I'm not familiar with SQL server syntax, but do your datatypes correspond? You are inserting strings, not numeric values (your names of your variables presume it would be a numeric value).

    Best regards,

    Wouter

    Tuesday, December 23, 2014 9:27 AM