开发者

Connecting to Oracle database

开发者 https://www.devze.com 2023-02-22 14:34 出处:网络
Today is my first day trying to use Oracle databases in Asp.NET so I have no idea of what I need to do.

Today is my first day trying to use Oracle databases in Asp.NET so I have no idea of what I need to do.

I have added this code

Dim oOracleConn As OracleConnection = New OracleConnection()
oOracleConn.ConnectionString = "Data Source=xxxxx;User Id=yyy;Password=psw;"
oOracleConn.Open()
Response.write("Connected to Oracle.")
oOracleConn.Close()
oOracleConn.Dispose()
End Sub

But it gives me the error

Type 'OracleConnection' is not defined.

Now i've had a look on the internet and it says that it may be the reference to the DLL that is missing?

I know I have got a DLL reference in my page and I don't think I even have the DLL anywhere on my server.

Where do I get this DLL from?

I've 开发者_运维技巧downloaded the ODBC .NET data provider but this didn't seem to help.

I've tried to add a reference in Visual Studio but I can't find the Oracle client reference in the list.

Any ideas?

Thanks


The Oracle recommended method is to use the Oracle Data Provider for .NET

You'll need an Oracle Client that is compatible with the version of the database you are using installed on your dev machine and the web sever machine.

There are some quirks with how you have to specify the database connection string. Some kind internet soul has documented the database connection strings for the oracle providers.

The oracle client has a file, called TNSNAMES.ORA, which is typically located in the /NETWORK/ADMIN folder under the oracle home where the client was installed (the installation location varies by version and installation settings).

This file contains a list of databases with the Port Number, Hostname, and Oracle SID which allows the oracle client to make a connection to a server.

Once all of this is configured (or you decide to use the "TNS-less" connection string), you should be able to make database connections to oracle.

The ODP.NET provider documentation also provides some sample code which is very helpful when getting started with it.


Per this, this OracleConnection is an obsolete API, however the DLL being used is:

System.Data.OracleClient.dll

EDIT: This article provides some data on different API's to connect to Oracle with .NET


The real problem is data type mapping,but not connection or provider .

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号