Connecting with ASP.Net
I am using asp.net to create a project and i need a connection string to connect it with an Oracle server which is on a LAN network.
I know its IP address, and port number I will arrange if required.
I saw all the connection string for Oracle but I got confused as to which one to chose.
Please help.
17 answers
Try using the ones for the ".NET Framework Data Provider for Oracle" if youre using asp.net.
Please provide the whole connection string and values for the parameter also.
thank you
i got the connection string but my problem is that the database is on a server.
i have the ip address and port number for it.
so where will i integrate these 2 parameters in the connection string??
Either in tnsnames.ora or if you want you can use a string like this one
Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=MyHost)(PORT=MyPort))(CONNECT_DATA=(SERVICE_NAME=MyOracleSID)));User Id=myUsername;Password=myPassword;
Change MyHost and MyPort with serveraddress and port. Let me know if its working.
thanks..
i will try it as soon as i can and will let you know..
I tried all this options
Dim myConnection As New OleDbConnection("Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=hostip)(PORT=1521))));Provider=msdaora;User Id=user;Password=pass;")
at first i didnt put the provider then it resulted into an error
[An OLE DB Provider was not specified in the ConnectionString. An
example would be, 'Provider=SQLOLEDB;]
so i placed th provider as msdaora and then it started showing a different error as
["ORA-12154: TNS:could not resolve the connect identifier specified"]
then i tried this
Dim myConnection As New OleDbConnection("Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=hostip)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=MyOracleSID)));Provider=msdaora;User Id=user;Password=pass;")
and got this error
[ORA-12514: TNS:listener does not currently know of service requested
in connect descriptor].
another option i tried was
(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=MyOracleSID) Dim
myConnection As New OleDbConnection("Data
Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=172.16.5.12)(PORT=1521))((CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=MyOracleSID);Provider=msdaora;User
Id=trainee;Password=trainee;")
and got this
ORA-12154: TNS:could not resolve the connect identifier specified
Please provide me a solution.
You are using the wrong provider.
Use this one with the connection string instead.
http://www.connectionstrings.com/net-framework-data-provider-for-oracle/
I did this today.
Dim myConnection As OracleConnection = New OracleConnection()
myConnection.ConnectionString = "Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=myhost)(PORT=myport))(CONNECT_DATA=(SERVICE_NAME=MyOracleSID)));User Id=user;Password=password;"
myConnection.Open()
MsgBox("reading")
myConnection.Close()
and got this error
ORA-12514: TNS:listener does not currently know of service requested
in connect descriptor
My guess is that the server does not understands this "MyOracleSID" cos server is the listner and the error msg says that it does not know of service requested in connect descriptor. What could be wrong.
I tried one more thing.
Dim myConnection As OracleConnection = New OracleConnection()
myConnection.ConnectionString = "Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=host)(PORT=port))(CONNECT_DATA=(SID="db")));User Id=user;Password=pass;"
myConnection.Open()
MsgBox("reading")
myConnection.Close()
it is giving this error
ORA-12505: TNS:listener does not currently know of SID given in
connect descriptor
Whats wrong?
Pease tell me complete connection string and how to use it in asp.net.
The values in the string is just example values. You must alter these values to the ones for your server.
For instance you must change the "user" (user id) to a valid user name at your oracle server.
The values that you should change in the example is;
- myhost
- myport
- MyOracleSID
- user
- password
Of cource i did changed those values. I changed the ip to the one i have to use and changed the port to "1521" thats the one we are using here.
But still it didn work the same error comes up again and again
ORA-12514: TNS:listener does not currently know of service requested
in connect descriptor
Please find a way out of it.
IS MYOracleSID the name of the database..??
i think i have tried that 2 but i think i will give it another go
Yes, it means "System ID", but the SID is unique per database.
Viki,
Did u manage to resolve your error:
ORA-12514: TNS:listener does not currently know of service requested
in connect descriptor
I have exactly the same problem and I have tried the options suggested in the previous responses.
Viki,
I was finally able to get the connection thru
Data Source=IP:PORT/ServiceName.XXX
XXX is a reference within your serviceName for an example others use world
Hope this works out for you also.
Lungisa Duna,
thanks... i will try that....
:)
Thank you, Lungisa Duna.
I have succeeded connecting oracle11g database in ASP.NET 4.0. But I have only succeeded in my localhost.
Oracle 11g is installed in localhost.
After succeeding in localhost, I was tried to connect oracle 10g db in other machine. Just here, I failed to do.
I have installed oracle client 11g home2 in my localhost. Why can't I connect the oracle 10g db in other machine?
Is the reason the oracle client 11g home2 in my local machine? What about it?
I will look forward to your correct reply.
I went round and round trying to get a connections through VBScript. Im running the scripts on Win08 x64 servers running 11g and retrieving data from an old Oracle 8 database.
I finally succeeded using the following connection string.
"Driver={Oracle in OraClient11g_home2};Dbq=MyTNSName;Uid=MyUserID;Pwd=MyPassword;"
OraClient11g_home1 would have worked too.
I have 2 drivers listed from attempting to reinstall the 11g ODBC drivers.