0
votes

I need connection on vb script with Db2 v10.5 to extract data from db2. DB2 database is on another machine. Though I am using one connection string in VBA excel which is working fine for me however same is not working in VB script.

Connection string in VBA (Excel)

=============================================================

  • Set objmyconn = New ADODB.Connection Set objmycmd = New ADODB.Command Set objMyRecordset = New ADODB.Recordset

    objmyconn.ConnectionString = "Data Source=XXXXXXX;User ID=XXXXX;password=XXXX;Provider=IBMDADB2.DB2COPY1;Persist Security Info=True;Location=;Extended Properties=;" objmyconn.Open

=========================================================================Earlier I am using Microsoft OLEDB provider for db2 in VB script but now I am using IBM db2 Oledb provider. A DB2 client already installed in my machine

1
If this is a question with VBA language why do you tag it with VB.NET? Please use appropriate tagsSteve
It is related with Vb script connection with DB2Rohit Lal

1 Answers

0
votes

In the VBA you have references set to the ActiveX Object Library and you declare your variables as datatype. VBScript doesn't use data type declarations. You need to use CreateObject to Set your object variables.

Set objmyconn = CreateObject("ADODB.Connection")
Set objmycmd = CreateObject("ADODB.Command")
Set objMyRecordset = CreateObject("ADODB.Recordset")