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.
Related
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
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/
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
Private Sub Form_Load()
Dim conString As String
conString = "Provider=Microsoft.Jet.OLEDB.4.0;" _
& "Data Source=D:\Dheeraj\VB6_DH\db5.mdb" _
& "Jet OLEDB:Database Password=dheeraj;" _
'& "App.Path & Persist Security Info=False;"
Set CON = New ADODB.Connection
With CON
.ConnectionString = conString
.Open
End With
End Sub
Hi,
here is the code to connect ms access database with password protection. However it is giving an error 'Could not use ";file already in use' can you please tell me what could be the issue.
Try to do this.
con.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\Masterfile.mdb;Jet OLEDB:Database Password=xxxxx;"
Missing ; between .mdb and Jet
conString = "Provider=Microsoft.Jet.OLEDB.4.0" _
& ";Data Source=D:\Dheeraj\VB6_DH\db5.mdb" _
& ";Jet OLEDB:Database Password=dheeraj;"
This is a connection string I just pulled from on of my (working) project:
"Provider='Microsoft.Jet.OLEDB.4.0';Data Source='%path%\%file%'; Jet OLEDB:Database Password=%pwd%;"
So I guess the database source should be enclosed in a pair of single-quotes.
EDIT: Cross that, it shouldn't make any difference (as with the single quotes around the provider name). I never read your question until the end.
Close any programs currently having the database open and then delete any *.ldb file left in the same directory as the database. If you cannot delete the *.ldb file, then it means there's still a process running that has that file open. Hunt it down and kill it, then retry deleting the file.
You need to add two ; before Jet OLEDB
And try this code for connection
Public Con as New ADODB.Connection
Private Sub Form_Load()
Dim conString As String
conString = "Provider=Microsoft.Jet.OLEDB.4.0;" _
& "Data Source=D:\Dheeraj\VB6_DH\db5.mdb" _
& ";;Jet OLEDB:Database Password=dheeraj;"
Con.Open conString
End Sub
Dim Con As ADODB.Connection
Dim DatabasePath As String
Dim DatabasePassword As String
DatabasePath = App.Path & "\Storage.mdb"
DatabasePassword = "mypc"
Set Con = New ADODB.Connection
With Con
.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Password='';" & _
"User ID=Admin;Data Source=" & DatabasePath & ";" & _
"Jet OLEDB:Database Password='" & DatabasePassword & "'"
.Open
End With
(Tearing my hair out, been doing this a million times for decades and now it doesn't work!) I have a simple VB6 program, connecting to SQL 2008 Express locally on the host machine. I can connect to the database using the same credentials in SQL Server Management Studio Express. However, when I run this code, I get the following error:
Run-time error '3706':
Method 'Open' of object '_Connection' failed
Dim DBConn As ADODB.Connection
Set DBConn = New ADODB.Connection
Dim ConnString As String
txtServer.Text = "R19DEV\SQLEXPRESS"
txtCatalog.Text = "MyDatabase"
txtUser.Text = "MyUser"
txtPassword.Text = "MyPassword"
ConnString = "Provider=SQLOLEDB.1;Persist Security Info=False;Initial Catalog=" & _
txtCatalog.Text & ";Data Source=" & txtServer.Text & ";User ID=" & txtUser.Text & _
";Password=" & txtPassword.Text
Debug.Print ConnString
DBConn.Open ConnString
Here's the connection string:
Provider=SQLOLEDB.1;Persist Security Info=False;Initial Catalog=MyDatabase;Data Source=R19DEV\SQLEXPRESS;User ID=MyUser;Password=MyPassword
OK, I'm not sure why this worked. I changed the connection provider from SQLOLEDB.1 to SQLOLEDB, and that fixed it.