ADO won’t work in VB6

ADO won’t work in VB6

Question:
What is wrong with this picture?

Private Sub cmdIXEDMtest_Click()    Dim con As New ADODB.Connection    Dim rs As New ADODB.Recordset    Dim s As String    Dim constr As String        On Error GoTo FunctionError    constr = "Provider=MSDASQL.1;Persist Security Info=False;User ID=scanctr_user;PWD=please;Data Source=32scanctr"    Set con = New ADODB.Connection    con.Open constr    If (con.State <> adStateOpen) Then        MsgBox "Connection failed!"    End If        Set rs = New ADODB.Recordsets = "SELECT * FROM Batch WHERE System_ID = '008945'"    rs.Open s, cons = rs("Has_DWG")<>        rs.Close    Set rs = Nothing        con.Close    Set con = Nothing    FunctionExit:    Exit SubFunctionError:    Set rs = Nothing    Set con = Nothing    MsgBox "Error: " & Err.Number & " " & Err.Description    Resume FunctionExitEnd Sub

Please offer any suggestions. I have tried different cursor types and specifying client-side cursor location. All to no avail and with the same, useless error message.

Answer:
From what it looks like, you’re not opening an editable Recordset. The rs.Open command needs to be followed (after the two arguments that are already there) by two more constants. The first specifies the cursor type. For an editable recordset, you need to use either adOpenDynamic or adOpenKeyset. The second argument specifies how to lock the recordset. In this case, you’re editing only a single record, so the lock can be an optimistic lock. Use the adLockOptimistic constant. The new line should look like this:

rs.Open s, con, adOpenDynamic, adLockOptimistic

At this point, the edit of the field should work fine.

Share the Post:
Heading photo, Metadata.

What is Metadata?

What is metadata? Well, It’s an odd concept to wrap your head around. Metadata is essentially the secondary layer of data that tracks details about the “regular” data. The regular

XDR solutions

The Benefits of Using XDR Solutions

Cybercriminals constantly adapt their strategies, developing newer, more powerful, and intelligent ways to attack your network. Since security professionals must innovate as well, more conventional endpoint detection solutions have evolved

AI is revolutionizing fraud detection

How AI is Revolutionizing Fraud Detection

Artificial intelligence – commonly known as AI – means a form of technology with multiple uses. As a result, it has become extremely valuable to a number of businesses across

AI innovation

Companies Leading AI Innovation in 2023

Artificial intelligence (AI) has been transforming industries and revolutionizing business operations. AI’s potential to enhance efficiency and productivity has become crucial to many businesses. As we move into 2023, several

data fivetran pricing

Fivetran Pricing Explained

One of the biggest trends of the 21st century is the massive surge in analytics. Analytics is the process of utilizing data to drive future decision-making. With so much of

kubernetes logging

Kubernetes Logging: What You Need to Know

Kubernetes from Google is one of the most popular open-source and free container management solutions made to make managing and deploying applications easier. It has a solid architecture that makes