Versión Completa : Conectar a base de datos ORACLE de otro pc
SuperCamilo
octubre 26, 2005, 02:22
Hola, como estan?, esta vez mi pregunta es como hago para conectarme a una base de datos oracle que este en otro pc desde mi aplicacion en visual basic.net, se que con sql server soloe s especificarle el nombre del equipo en el connection string pero como el connection string de otracle es diferente entonces no se como pueda especificarle que la base de datos se encuentra en otro pc, muchisimas gracias!
Dios los bendiga!
Grissom.
octubre 26, 2005, 05:20
Crea un origen de datos ODBC (data source) apuntando a la base de datos remota. De este modo le das el nombre del datasource en la cadena de conexión como si fuera local, ODBC abstraería todo.
Suerte.
SuperCamilo
octubre 27, 2005, 10:40
Crea un origen de datos ODBC (data source) apuntando a la base de datos remota. De este modo le das el nombre del datasource en la cadena de conexión como si fuera local, ODBC abstraería todo.
Suerte.
Muy buen a porte bro, lo voy a tener en cuenta, la vaina es que tengo todo el software hehco con oledb y para conectar con odbc se debe hacer con la clase odbc o sea que me tokaria cambiar muchas partes del codigo y es bastante larguito, si saben alguna forma de hacerlo por oledb, asi sea configurando el oms de oracle les agradecería mucho aun que tu idea rulas es un buen salvavidas, muchas gracias!
SuperCamilo
octubre 28, 2005, 09:59
Ya en contre la forma, lo que pasa es que oracle maneja el acceso a sus instancias por emdio d eun archivo que se llama tnsnames.ora ubicado en la carpeta C:\ORANT\network\ADMIN\ y desde ahi le especifica el nombre del pc y toda la vaina, mejor dicho aqui les dejo este post que encontré y como dice la autora espero que les sea de ayuda a algunos,
Dios loe bendiga!
Oracle connection error 12514
Connecting Oracle 10g to .NET
Below are someone's successful steps -
First of all, I had to install the client part of Oracle 10g, and I installed everything, just to be sure that I didn't miss anything (485
Megabyte, Oracle Enterprise Manager included).
Then... I wrote this code:
OracleConnection myConnection = new OracleConnection("User
Id=ANDREA;Password=ASDASD;Data Source=WIN2003");
myConnection.Open();
Of course the username ANDREA exists in Oracle, the password is the right one and the server name is WIN2003 (if I ping WIN2003 it replies back correctly). Before trying to connect with .NET I verified that the Oracle Enterprise Manager (java version, not the web version) worked fine.
BUT!!!! I get this error...
ORA-12514: the listener doesn't recognize the requested service in the connection descriptor
(Sorry if the message doesn't match, but I am Italian and my message was in Italian, so I had to translate it!)
I didn't have much luck with google. I tried to look for these keywords
OracleConnection 12514 but I got no results. So I found the solution myself. The Oracle's listener seems to identify the .NET connection using the same entry that you can find in the file "tnsnames.ora". This is my file:
# tnsnames.ora Network Configuration File:
C:\Oracle\product\10.1.0\Client_1\NETWORK\ADMIN\tn snames.ora
# Generated by Oracle configuration tools.
ORCL_WIN2003 =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = WIN2003)(PORT = 1521))
)
(CONNECT_DATA =
(SID = ORCL)
(SERVER = DEDICATED)
)
)
EXTPROC_CONNECTION_DATA =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC))
)
(CONNECT_DATA =
(SID = PLSExtProc)
(PRESENTATION = RO)
)
)
Do you see that ORCL_WIN2003? Well, THAT is Data Source parameter that must be used in the connection string! That ORCL_WIN2003 is the result of the SID and the host name that you enter when you add a new database in the Oracle Enterprise Manager. So, my advice is: try to connect usingn the Oracle Enterprise Manager first, take a look in the "tnsnames.ora" file and then write your code.
The working version of my code is:
OracleConnection myConnection = new OracleConnection("User
Id=ANDREA;Password=ASDASD;Data Source=ORCL_WIN2003");
myConnection.Open();
Hopefully some one will benefit from this one day :-), plus it is a good peice of info to keep on my blog.
vBulletin®, Copyright ©2000-2008, Jelsoft Enterprises Ltd.