Article ID: 197528
Article Last Modified on 3/2/2005
Option Explicit
Private Sub Command1_Click()
Dim cn As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim rst As ADODB.Recordset
Dim Str As String
With cn
.Provider = "SQLOLEDB"
.Open "Data Source=Test;User ID=<user name>;Password=<strong password>;"
.DefaultDatabase = "Pubs"
End With
' Un-comment the following line to demonstrate Workaround 1
' cn.Execute "SET NOCOUNT ON "
' Passing an Insert statement followed by a Select statement
' as the source of the recordset
Str = "Insert into Jobs (job_desc, min_lvl, max_lvl) Values " _
& "('Support Professional', 25, 75) " _
& " Select * from Jobs"
rs.CursorLocation = adUseClient
rs.Open Str, cn, adOpenStatic, adLockOptimistic, adCmdText
' Un-comment the following two lines to demonstrate Workaround 2
' Set rs = rs.NextRecordset
' For workaround 2, please comment the following line
MsgBox rs(1)
MsgBox "Done..."
cn.Close
End Sub
Keywords: kbdatabase kbprb KB197528