QTP connection string for Sybase 16 database? - vb6

I can't seem to get my connection string correct.
Dim conn, rs
Set conn= createobject("adodb.connection")
set rs = createobject("adodb.recordset")
conn.Open "Provider=Sybase.ASEOLEDBProvider;Server Name = xxx.xxx.xxx.xxx,yyyy;User Id=user;Password=pwd;Database=mydatabase;"
rs.open "Select * from blah", conn
I keep getting an error stating, "Provider cannot be found. It may not be properly installed."
I know the provider is installed because I use the same computer for coding up C# applications that connect to Sybase 16 successfully all the time. Does anyone know the correct connection string for QTP/UFT?

I figured it out.
Dim conn, rs
Set conn= createobject("adodb.connection")
set rs = createobject("adodb.recordset")
conn.Open "Driver={Adaptive Server Enterprise}; Server=xxx.xxx.xxx.xxx; port=yyyy; uid=user; pwd=pwd; db=mydatabase;"
rs.open "Select * from blah", conn
Using this you'll be able to use QTP/UFT and connect to a sybase 16 database - so long as you have have the Sybase Adaptive Server Enterprise drivers installed on your system. It's a proprietary database and to my knowledge you'll have to either purchase drivers directly from Sybase or from a thrid party. If you're running Sybase 16 at your company you more than likely have the ASE drivers - ask around.

There is way to connect if it is in windows 7 Function
ConnectionTest()
DB_CONNECT_STRING = "Provider=OraOLEDB.Oracle; Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=" & myHostName & ")(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=" & myServiceNameOrSID & "))); User ID=" & myUsername & ";Password=" & myPassword & ";"
Set myConn = CreateObject("ADODB.Connection")
Set objRecordSet = CreateObject("ADODB.Recordset")
myConn.Open DB_CONNECT_STRING
objRecordSet.Open myQuery, myConn
Wscript.Echo objRecordSet.fields.item(1) & " " & objRecordSet.fields.item(2)
myConn.Close
End function
Call ConnectionTest()
if there is problem in mapping adodb driver need to invoke the exe file before running in windows 64 bit

Related

VBScript_Get xml data stored in Oracle DB(DataType - CLOB)

This may seem to be a pretty basic issue but I am not able to find any solution for this. I have to admit that I have very little experience with databases. I looked at THIS question but it didn't help me much.
Issue:
Whenever I modify my query to fetch data of type CLOB from the database, I get the error "Unspecified Error". In the below code, I have written the query strQuery = "select CDATA from WR2_USR.router_xml_data where EVENT_ID= '987787454'". The column CDATA(of datatype CLOB) contains an Long XML which I need to fetch and store in a variable for further use. Is there any way to achieve that?
Code:
Option Explicit
Dim objCon, objRs, strCon, strQuery, i, strServer, strUid, strPwd
set objCon = CreateObject("adodb.connection")
set objRs = CreateObject("adodb.recordset")
strServer = "" 'Contains the correct Server information
strUid = "" 'Contains the user name
strPwd = "" 'Contains the password
strCon = "Driver={Microsoft ODBC for Oracle};SERVER="&strServer&";uid="&strUid&";pwd="&strPwd &";"
strQuery = "select CDATA from WR2_USR.router_xml_data where EVENT_ID= '987787454'"
objCon.open strCon
if objCon.state=1 then
objRs.open strQuery, objCon '<--- GETTING ERROR HERE
while (not objRs.eof)
msgbox objRs.fields.count
for i=0 to objRs.fields.count-1 step 1
msgbox cstr(objRs.fields.item(i).value)
next
objRs.movenext
Wend
end if
set objCon = Nothing
set objRs = Nothing
Error:
Column Details:
NOTE: If I change my query to fetch some other Column's data(not of CLOB datatype), the code runs fine.
ODBC Driver for Oracle from Microsoft is deprecated for ages:
Oracle 7.3x is supported fully; Oracle8 has limited support. The ODBC Driver for Oracle does not support any of the new Oracle8 data types — Unicode data types, BLOBs, CLOBs, and so on — nor does it support Oracle's new Relational Object Model.
Use the ODBC driver or OLE-DB Provider from Oracle, you can download from Oracle Data Access Components (ODAC) for Windows Downloads
Then the connection string has to look similar to this:
' ODBC Driver from Oracle
strCon = "Driver={Oracle in OraClient11g_home1};DBQ=" & strServer & ";Pwd=" & strPwd & ";Uid=" & strUid
' OLE DB Provider from Oracle
strCon = "Provider=OraOLEDB.Oracle;Data Source=" & strServer & ";Password=" & strPwd & ";User ID=" & strUid

VB6 application ado connection for TLS1.2

I have to support a VB6 application that is still in production (ugh). A customer is specifying our software needs to be PCI compliant which requires TLS 1.2.
Anyone know how to do this?
I am using SQL Server 2014. I'm patched to build 12.0.4502.0.
Public Function GetConnection() As ADODB.Connection
Dim con As ADODB.Connection
On Error Resume Next
Set con = New ADODB.Connection
con.ConnectionTimeout = 10
Dim connstring As String
'connstring = "Provider=SQLOLEDB;Server=" & gstrServer & ";Database=" & gstrDB & ";User Id=" & gstrUser & ";Password=" & gstrPwd
connstring = "Provider=MSDASQL;DRIVER=Sql Server;Server=" & gstrServer & ";Database=" & gstrDB & ";UID=" & gstrUser & ";PWD=" & gstrPwd
con.Open connstring
If Err Then Set con = Nothing
Set GetConnection = con
End Function
The project is referencing "Microsoft ADO Ext. 6.0 for DDL and Security" and "Microsoft ActiveX Data Objects 2.5 Library"
I have tried multiple connection string options.
Thanks!
I found the answer in Using ADO with SQL Server Native Client.
To enable the usage of SQL Server Native Client, ADO applications will
need to implement the following keywords in their connection strings:
Provider=SQLNCLI11
DataTypeCompatibility=80
The following is an example of establishing an ADO connection string that is fully enabled to work
with SQL Server Native Client, including the enabling of the MARS
feature:
Dim con As New ADODB.Connection
con.ConnectionString = "Provider=SQLNCLI11;" _
& "Server=(local);" _
& "Database=AdventureWorks;" _
& "Integrated Security=SSPI;" _
& "DataTypeCompatibility=80;" _
& "MARS Connection=True;"
con.Open
Changing the provider to SQLNCLI11 and adding DataTypeCompatibility=80 worked.

Vb conncetion string to Oracle DB

How will look connection string to Oracle db if I have such parameters:
HOST = host
PORT = 1531
SERVICE_NAME = service_name
User: USER_ADMIN
pass: USER_ADMIN
Now I have connection string like this:
set oConn = CreateObject("ADODB.Connection")
oConn.ConnectionString = "Provider=OraOLEDB.Oracle;Data Source=host/orcl;Persist Security Info=True;User ID=user;Password=password;Unicode=True;Driver={Microsoft ODBC for Oracle};"
oConn.Open
Correct me please!
Your connection string is wrong, you cannot use Provider=OraOLEDB.Oracle and Driver={Microsoft ODBC for Oracle} at the same time.
In case you like to use the Oracle OLE DB provider try this:
Set oConn = CreateObject("ADODB.Connection")
oConn.provider = "OraOLEDB.Oracle"
DB = host & ":" & port & "/" & SERVICE_NAME
oConn.Open "Data Source=DB", User, pass
which should be equivalent to:
Set oConn = CreateObject("ADODB.Connection")
DB = host & ":" & port & "/" & SERVICE_NAME
oConn.Open "Provider=OraOLEDB.Oracle;Data Source=DB;User Id=" & User & ";Password=" & pass
However, I do not know whether Oracle OLE DB supports Easy Connect Naming Method (EZ), I never used it. In case it does not support EZ try this one instead:
DB = "(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=" & host & ")(PORT=" & port & "))(CONNECT_DATA=(SERVICE_NAME=" & SERVICE_NAME & ")))"
Actually such definition should be written in tnsnames.ora file, e.g.
DB_TNS.your.domain =
(DESCRIPTION=
(ADDRESS=(PROTOCOL=tcp)(HOST=host)(PORT=1531))
(CONNECT_DATA=
(SERVICE_NAME=service_name)
(SERVER=server)
(INSTANCE_NAME=instance_name)
)
)
Then you can simply use oConn.Open "Data Source=DB_TNS", User, pass
In case you prefer to use the ODBC driver (although the ODBC driver from Microsoft is deprecated) use this one: ADO ConnectionStings

Oracle Can connect from client but not from script - invalid user/password

I'm trying to connect to a Oracle DB and i believe the version is 12c, I'm able to connect to the same DB using a client (SQL Developer), but having issues while trying to connect using VBscript which I would like to use as part of my application.
Here is the error message --
**Exception: OraOLEDB - ORA-01017: invalid username/password; logon denied**
Here is my script that I'm using to connect --
Option Explicit
On Error Resume Next
'Dim strSQLQuery: strSQLQuery = "SELECT sysdate FROM dual"
Dim strDBDesc: strDBDesc = "(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP) (HOST = XXX)(PORT = XXX))(CONNECT_DATA =(SERVER = DEDICATED)(SERVICE_NAME = XXXX)))"
Dim strUserID: strUserID = "user"
Dim strPassword: strPassword = "pass"
Dim ADODBConnection: Set ADODBConnection = CreateObject("ADODB.Connection")
Dim strConnection
strConnection = "Provider=OraOLEDB.Oracle;Data Source=" & strDBDesc & _
";User ID=" & strUserID & ";Password=" & strPassword & ";"
ADODBConnection.Open strConnection
If Err <> 0 Then
WScript.Echo "An error occurred in Opening Connection: " & Err.Number & " " & Err.Description & " " & Err.Source
End If
Set ADODBConnection = Nothing
Is the password simple or with special character? use an escape sequence or quotes if with special characters.
Based on below use "ADODBConnection.ConnectionString = strConnection" in the above snippet and then open the connection.
Place break point and see what is being passed as a connection string to the driver.
Refer: https://docs.oracle.com/cd/E47955_01/win.121/e18594/using.htm
All,
i was able to connect successfully after i have download and installed the latest copy of Oracle ODAC from their website.
here are additional details - hope this helps others having a similar issue
https://blogs.msdn.microsoft.com/dbrowne/2013/10/02/creating-a-linked-server-for-oracle-in-64bit-sql-server/

Infobright database connection through vb script

Can anyone tell me how to connect infobright database through vb script. I have written a code but it shows an error:
provider can not be found.
The code I have written is:
Option Explicit
Dim conn, sqlstr
sqlstr = "SELECT COLLATION_NAME FROM COLLATIONS"
'Database connection info
set Conn = CreateObject("ADODB.connection")
Conn.ConnectionTimeout = 30
Conn.CommandTimeout = 30
conn.open("Provider=Microsoft.Jet.OLEDB.4.0;Database=information_Schema;Username=root;Password=''")
dim showList
Set showList = conn.execute(sqlstr)
while not showList.eof
Wscript.echo "Collation Name:" & showList("COLLATION_NAME")
showList.MoveNext
WEND
conn.close
Install MySQL Connector/ODBC 5.1 and use a connection string like the following
connString = "Driver={MySQL ODBC 5.1 Driver};Server=ServerAddress;Database=DataBase;User=Username; Password=Password;"

Resources