连接到Oracle数据库 [英] Connecting to Oracle database

查看:229
本文介绍了连接到Oracle数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

今天是我第一天尝试使用Oracle数据库在Asp.NET所以我没有什么,我需要做的想法。

我加入这个code

 昏暗oOracleConn作为的OracleConnection =新的OracleConnection()
oOracleConn.ConnectionString =数据源= XXXXX;用户ID = YYY;密码= PSW;
oOracleConn.Open()
回复于(连接到Oracle。)
oOracleConn.Close()
oOracleConn.Dispose()
结束小组

但它给我的错误


  

类型的OracleConnection没有定义。


现在我已经有在互联网上一看,它说,它可能是参考DLL的丢失?

我知道我有我的页面DLL参考,我不认为我甚至有DLL我的服务器上的任意位置。

我在哪里可以得到从这个DLL?

我已经下载了ODBC .NET数据提供程序,但这似乎并没有帮助。

我试图添加在Visual Studio中的引用,但我不能在列表中找到Oracle客户端的参考。

任何想法?

感谢


解决方案

Oracle的推荐方法

是使用的 Oracle数据提供程序.NET

您将需要一个Oracle客户端是与数据库您正在使用您的开发计算机上安装的版本和网页服务器设备不兼容。

有一些怪癖你怎么也得指定数据库连接字符串。一些互联网的灵魂记录为Oracle提供商的数据库连接字符串。

Oracle客户端有一个文件,名为TNSNAMES.ORA,通常位于在被安装在客户端的Oracle主目录下的/网络/ ADMIN文件夹(安装位置按版本和安装设置不同而不同)。

本文件包含的端口号,主机名和Oracle SID数据库的列表,它允许Oracle客户端进行与服务器的连接。

在所有这些配置(或者你决定使用TNS-少连接字符串),你应该能够作出的Oracle数据库连接。

在ODP.NET提供程序文档也提供了一些示例code开始使用它时,这是非常有帮助的。

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.

这篇关于连接到Oracle数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆