I am trying to connect to oracle server from excel...i dont want to install oracle client in my system(presently there is no oracle client) So i am using Microsoft ODBC for Oracle
Dim strConnection, conn, rs, strSQL
strConnection = "Driver={Microsoft ODBC for Oracle};Server=ServerName;Uid=username;Pwd=password;"
Set conn = CreateObject("ADODB.Connection")
conn.Open strConnection
'insq = "insert into State (States) values ('" + Sheet1.Cells(1, 5) + "')"
'conn.Execute insq
conn.Close
Set conn = Nothing
The Error is : Oracle Client and networking component not found
I have also tried using connection string
trConnection = "Provider=OraOLEDB.Oracle;Data Source=Datasource;User Id=username;Password=password;"
'strConnection = "Provider=MSDAORA;Data Source==Datasource;User Id=username;Password=password;"
But still i am getting an error
My main question is can we connect from excel to oracle server without oracle client
in my system..
Ultimately you need something on your system that 'speaks Oracle'. To begin with it needs to know how the protocol works to get the specified password accepted by Oracle, even before it gets into doing anything with data.
You are best off installing the Instant Client (Basic and ODBC supplement).
Related
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.
I have 2 servers, a win2000+ Classic ASP application server, the other is Server 2012 with a SQL 2012 instance.
On the application server I can create an ODBC DSN (name is "test") to connect to the SQL instance, and access database (mdb). I use "test" to link tables in B, so the connection is fine. But on my ASP page I cannot connect to the SQL instance, and an error message is displayed: "SQL Server does not exist or access denied".
Here's my code:
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.open "DSN=test;UID=user;PWD=pwd;DATABASE=test"
conn.close
set conn = nothing
response.write "ok"
Try this?
Dim MM_MyServer_STRING
MM_MyServer_STRING = "SERVER=test;DATABASE=test;user id=user;password=pwd"
Set ConnectMe = Server.CreateObject("ADODB.Recordset")
ConnectMe.ActiveConnection = MM_MyServer_STRING
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.