I set up an ODBC connection using ODBC Data Source Administrator . I have named it "BIOTPL" connect like this:
The corresponding code is :
Set Conn = Server.Createobject("ADODB.Connection")
Conn.Open "Provider=OraOLEDB.Oracle;Data Source=simple_dsn;User Id=USER;Password=PASSWORD;"
But I am getting this error .
ORA-12154: TNS:could not resolve the connect identifier specified
How can I solve this error ? Please help me .
The following code works for me .
Set Conn = Server.Createobject("ADODB.Connection")
Conn.open "Driver={Oracle in OraDb11g_home1};Server=10.11.201.170; Uid=USER;Pwd=PASSWORD;"
This is how I connect to Oracle using VBscript.
ConnectionString = "Driver={Microsoft ODBC for Oracle}; CONNECTSTRING=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=" + DBCONN + ")(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=" + DatabaseSID + " ))); uid=" + DatabaseUser + ";pwd=" + DatabasePassword + ";"
Set objConnection = CreateObject("ADODB.Connection")
objConnection.Open ConnectionString
I had a similar error when using classic ASP and Conn.Open "Provider=OraOLEDB.Oracle..." as is shown in the code above.
However, if I used Conn.Open "DSN=MyDSN;User ID=..." the connection worked.
In order to use the "Provider=OraOLEDB.Oracle..." syntax, I had to create a 32-bit application pool in IIS - create the application pool, then set Enable 32-Bit Applications = True (in advanced settings).
Note that 64-bit Windows has both 32 and 64-bit ODBC configurations. The default ODBC manager is 64-bit. Classic ASP applications can run in 64-bit mode and use 64-bit ODBC DSNs with some limitations like using Conn.Open "DSN=MyDSN;User ID=...".
If you use the Conn.Open "DSN=MyDSN..." syntax and you run in 32-bit mode, you will need to configure the DSN using the 32-bit ODBC manager. To access the 32-bit ODBC manager, run C:\Windows\SysWOW64\odbcad32.exe
The 32-bit and 64-bit ODBC manager windows look identical - there will just be different lists of DSNs that are configured.
One other tool that I found helpful is to create a file named DBConnection.udl. (The file name is not important - just the .udl suffix.) When you double-click the file, a Data Link Properties window will open and allow you to select the provider and connection info. There is also a test button to verify your connection. After setting the connection variables, close the window and open the DBConnection.udl file with a text editor (notepad.exe works) and it will display the OLEDB init string that can be used in your application.
Related
We are getting error while trying to connect UFT with Redshift:
Dim dbConnection
Srvname = "Driver={Amazon Redshift (x64)};Server=serverName; Database=DBName; UID=****; PWD=****; Port=****;"
Set dbConnection = CreateObject("ADODB.Connection")
dbConnection.Open Srvname
Error coming as:
Datasource name not found and no default driver specified.
But with all same credential we can able to connect redshift with "SQL Workbench".
SQL Workbench is using a different Connector (most probably JDBC or some other technology). The ADODB.Connection Object is trying uses the ODBC Drivers installed for the Operating System, so first things frist you need to install the ODBC Driver.
After this is don, depending on your credential management policy, you may need to simply use the proper Connection String or configure stuff in the ODBC wizard of Microsoft Windows.
SQL Workbench uses Amazon Redshift JDBC compatible driver. Try downloading ODBC driver. Follow the below link
I have a working excel macro that connects using the following connection type:
Set cn = New ADODB.Connection
Set rs = New ADODB.Recordset
cn.Open ( _
"User ID=userid" & _
";Password=pass" & _
";Data Source=blank.blank.com" & _
";Provider=MSDAORA.1")
I can connect in one part of my network but when I try to use the same macro on another computer I can no longer connect. My thought is there is a networking issue and I need to be "more specific". So after some googling I've come across other data connection strings that utilize IP and port name.
Driver={Microsoft ODBC for Oracle};
Server=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=199.199.199.199)(PORT=1523))(CONNECT_DATA=(SID=dbName)));
Uid=myUsername;Pwd=myPassword;
Coming from https://www.connectionstrings.com/microsoft-odbc-for-oracle/
Following Microsofts documentation then I get the following:
With cn
.Provider = "MSDAORA.1"
.ConnectionString = "Driver={Microsoft ODBC for Oracle};" & _
"Server=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=1.1.1.1)(PORT=xxxx))(CONNECT_DATA=(SID=DB)));" & _
"Uid=userid;Pwd=pass;"
.Open
End With
However I get an error: ORA-12560 TNS:Protocol adapter error
Some solutions indicate that I should restart the database, but it's running! I connect to it just fine the other way.
Does anyone have a better way of connecting "more specifically" that might help my networking problem or might be able to help me fix up my new way of connecting?
I have always used the option you originally used. The fact that it works on one machine and does not work on another indicates to me that you do not have the MSDAORA driver installed on the second computer. The machine requires that the ODBC driver exists on the machine for your code to function.
Go to ODBC and make sure you can create a test connection via the ODBC panel on the second machine to make sure ODBC is functional for the MSDAORA driver.
I see there is no test connection when using Microsoft ODBC for Oracle. There is for the Oracle driver. One way to test it is to open MS Access and create a linked table, using the Microsoft ODBC connection you created. It will prompt you for a password and if it succeeds you will link the table, and know it is working, or it will give you an ODBC error, and you will know it is not.
Or you could use the Oracle driver, which would require installing the Oracle Client driver, and changing your connection information to reflect that driver instead of the MS one.
This works fine for me:
Set cn = New ADODB.Connection
Set rs = New ADODB.Recordset
cn.Open ( _
"User ID=userid" & _
";Password=pass" & _
";Data Source=blank.blank.com" & _
";Provider=MSDAORA.1")
I'm using QTP 10.
Trying to connect to Oracle DB via oracle client 10.2(windows xp).
I had prev oracle 9i & i've upgraded it to 10.2 thought it would resolve.
But still i'm getting "fatal two-task communication protocol error".
Is there any solution for that .
i see the same client version is working with windows 7 & oracle 10.2.
Appreciate your help..
I am using ADODB to connect to Oracle 10 and 11 from QTP (from VBScript in generall).
The code to connect is:
Set connection = createobject("adodb.connection")
connection.open "Driver={Microsoft ODBC for Oracle};" + _
"Server=host:1521/database_sid;Uid=username;Pwd=password;"
where:
host - is a server name where Oracle is running
1521 - is a port number (1521 is default port, but could be different on your system)
database_sid - is a SID of the database
You need to ask your database administrator for these values.
This code requires Oracle Instant Client.
You need to download proper package for your system (Win 32, Win 64 etc.) from here: http://www.oracle.com/technetwork/database/features/instant-client/index-097480.html
Unpack it to any directory and place this directory in a PATH environment variable.
and then, the code to execute queries and get results looks like this:
Set rs = createobject("adodb.recordset")
rs.open "SELECT fieldname FROM table WHERE etc.", connection
while not rs.eof
value = rs.fields( "fieldname" )
.....
loop
I just replaced the hard drive on my Windows 7 machine (my development computer). I did not have any issues with this working on the old hard drive, but I think I remember I had to change something or install something, but I do not remember.
The following code works perfectly on my live machine (Windows 2003 with IIS6).
OracleConn = "Provider=MSDASQL.1;Persist Security Info=True;User ID=TheUID;Password=ThePW;DSN=TheDB;DBQ=ORA_PRD1;"
SqlStr = "SELECT * FROM TestTable WHERE Somefield = 'Something'"
Set Objrs = Server.CreateObject("ADODB.RecordSet")
Objrs.Open SqlStr, OracleConn, adOpenStatic, adLockOptimistic,adCmdText
While Not Objrs.EOF
Response.Write "Some Stuff and whatever <br>"
Objrs.MoveNext
Wend
Objrs.Close
Set Objrs = Nothing
When I run it, I am getting the following error:
Microsoft OLE DB Provider for ODBC Drivers error '80004005'
[Microsoft][ODBC Driver Manager] Driver's SQLSetConnectAttr failed
I did create a .udl file to get the connection string and to test the database connection and it works fine. I also have an app on my computer that uses the same ODBC drivers to connect to the same database and it works fine.
I dont have any issues connecting to an Access database at all. Connecting to Oracle seems to be the only issue I am having.
I have a classic ASP site connecting to an Access database. Recently it's been moved from AT&T web hosting to a dedicated Cloud Server running Windows Server 2012. When the site hit's a line of code to query the database it returns an error:
Microsoft VBScript runtime error '800a01a8'
Object required
/menu.asp, line 145
The connection is happening in a different file and looks like:
<%
Set Conn = Server.CreateObject("Adodb.Connection")
Dim conStr
Conn.Open = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("/data/CNCmachinery.mdb")
%>
The line that throws the error is:
Set RP=Conn.Execute(msql) 'msql contains a basic query
Again, this site was working before the move to a new server, so I'm wondering if it's a compatibility issue? What should I be looking in to?
Was your old server a 32 or 64 bits machine? Windows server 2012 only runs over 64 bits machines and there is not version of 64 bits for Microsoft.Jet.OLEDB.4.0.
It seems ASP application can't create the object Conn due to the Provider in connection string:
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("/data/CNCmachinery.mdb")
If you old server was a 32 bits or a 64 bits but a version of 32 bits of Office installed, try this please:
1) Installing in your windows server 2012 the Office System Driver: Data Connectivity Components: Office 2007 version or Office 2010 version (Depending your version of Office installed in Windows Server 2012
2) Change the connection string to something like this:
Conn.Open = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & Server.MapPath("/data/CNCmachinery.mdb")
Assuming that you have moved from a 32 bit to a 64 bit server, which is very likely, there are two things you can try
First, enable 32 bit compatibility via IIS manager. (It's disabled by default)
https://help.webcontrolcenter.com/KB/a1114/how-to-enable-32-bit-application-pool-iis-7-dedicatedvps.aspx
Second, does the IUSR account associated with your website have read/write permission on your mdb file. Right click on the file and select the security tab to check