santhosh
santhosh

Reputation: 51

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

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

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

please help me..

Upvotes: 5

Views: 13835

Answers (1)

Paul Sasik
Paul Sasik

Reputation: 81459

It depends on the data provider. See: ConnectionString.com And 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.

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 tutorial you can follow that is ASP.NET-specific. And another article that may be of interest.

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

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];
}

Upvotes: 3

Related Questions