Question & Answer
Question
How can I connect to NPS using an ADO vb script and a DSNless connection?
Answer
Use a sample ADO script to connect through either ODBC or OLE-DB. Note that as a prerequisite, the Netezza OLE-DB driver must be installed on the client system.
By modifying a simple ADO vbscript, you can use it to connect to NPS using OLE-DB:
1. Open the sample script in a text editor.
2. Replace <connection string> with following connection string, which also requires that you provide values for the Password, User ID, Data Source and Initial Catalog fields.
- Provider=NZOLEDB;Password=<password>;User ID=<userid>;Data Source=<datasource>;Initial Catalog=<initcatalog>;Persist Security Info=True;SSL Security Level=1;Logging Level=0;
3. Replace <table name> with the name of the available table.
4. Save your changes to the vbs file.
5. In a command window, run the vbscript as follows:
- wscript <filename.vbs>
Sample vbscript
- Set gblCnxn = CreateObject("ADODB.Connection")
set rs = CreateObject("ADODB.Recordset")
Set cmd = CreateObject("ADODB.Command")
strConn = <connection string>
gblCnxn.open strConn
Wscript.Echo("::Connection opened::")
cmd.CommandText = "select * from <tablename>;"
Wscript.Echo("::Select query::")
cmd.ActiveConnection = gblcnxn
rs.Open cmd
if rs.EOF = -1 Then
Wscript.Echo("0 rows selected")
Else
Do Until rs.EOF
str1 = ""
For Each fldLoop In rs.Fields
str1 = str1 & fldLoop.Value & Chr(9)
Next
rs.movenext()
Wscript.Echo(str1)
Loop
End If
gblcnxn.close
Historical Number
NZ831725
Was this topic helpful?
Document Information
More support for:
IBM PureData System
Software version:
1.0.0
Document number:
466775
Modified date:
17 October 2019
UID
swg21574919