如何使用 Asp.Net 连接到 Oracle 11g 数据库

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4468199/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-18 22:13:41  来源:igfitidea点击:

how to connect to Oracle 11g database using Asp.Net

c#asp.netoracle

提问by santhosh

How do I connect to an Oracle 11g database using asp.net3.5?

如何使用 asp.net3.5 连接到 Oracle 11g 数据库?

what is the name space and how to write connection string in web.config file?

什么是命名空间以及如何在 web.config 文件中写入连接字符串?

please help me..

请帮我..

回答by Paul Sasik

It depends on the data provider. See: ConnectionString.comAnd perhaps more specifically: The .NET Data Provider for Oracle. The connection string should look very similar in your web.config file. The only differences, obiously, will be the system/db name(s), user id, pwd etc.

这取决于数据提供者。请参阅:ConnectionString.com或许更具体地说:Oracle 的 .NET 数据提供程序。连接字符串在您的 web.config 文件中看起来应该非常相似。唯一的区别显然是系统/数据库名称、用户 ID、密码等。

Namespaces:

命名空间

it is necessary to know which type of objects can have the same name and which are not. For this it is necessary to introduce the concept of a namespace. A namespace defines a group of object types, within which all names must be uniquely identified—by schema and name. Objects in different namespaces can share the same name.

有必要知道哪些类型的对象可以具有相同的名称,哪些不能。为此,有必要引入命名空间的概念。命名空间定义了一组对象类型,其中的所有名称都必须唯一标识——通过模式和名称。不同命名空间中的对象可以共享相同的名称。

Here's also a nice tutorialyou can follow that is ASP.NET-specific. And another articlethat may be of interest.

这也是一个很好的教程,您可以遵循它是特定于 ASP.NET 的。和另一篇可能感兴趣的文章

And a code snippet (using .NET Oracle provider:)

和一个代码片段(使用 .NET Oracle 提供程序:)

public DataTable myDataTable(string SQL, string ConnStr)
{
    OracleConnection cn = default(OracleConnection);
    DataSet dsTemp = null;
    OracleDataAdapter dsCmd = default(OracleDataAdapter);

    cn = new OracleConnection(ConnStr);
    cn.Open();

    dsCmd = new OracleDataAdapter(SQL, cn);
    dsTemp = new DataSet();
    dsCmd.Fill(dsTemp, "myQuery");
    cn.Close();
    return dsTemp.Tables[0];
}