Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Trying to connect to an AS/400 using OLE-DB & Client Express

Status
Not open for further replies.

wvjim

Programmer
Jan 11, 2001
25
US
I've downloaded the connection string from a site on the internet and get an error message "Run-time error '91': Object variable or With block varible not set" when I try to execute the visual basic program when it tries to open the connection.

The following are the variables I've defined and the connection string:

Dim cmd As ADODB.Command
Dim rs As ADODB.Recordset
Dim SqlCode As String
Dim AS400_Conn As ADODB.Connection


AS400_Conn.Open "Provider=IBMDA400;" & _
"Data source=CDS;" & _
"User Id=JIM;" & _
"Password=mypassword;" & _
"Transport Product = Client Access" & _
"SSL=Default"

The error occurs on the open command. TIA!

 
You need to instantiate instances of the following three objects.

You can either do this

Dim cmd As New ADODB.Command
Dim rs As New ADODB.Recordset
Dim AS400_Conn As New ADODB.Connection

AS400_Conn.Open "Provider=IBMDA400;" & _ ...

or

Dim cmd As ADODB.Command
Dim rs As ADODB.Recordset
Dim AS400_Conn As ADODB.Connection

Set cmd = New ADODB.Command
Set rs = New ADODB.Recordset
Set AS400_Conn = New ADODB.Connection

AS400_Conn.Open "Provider=IBMDA400;" & _ ...

and be sure to clean up when you're done

Set cmd = Nothing
Set rs = Nothing
Set AS400_Conn = Nothing
Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top