简体   繁体   中英

What is the alternative for System.Data.OracleClient.OracleCommand?

Can anyone share a link to sample (ASP).Net code that uses the new Oracle Data Provider.Net library?

I have code a web application code that uses the System.Data.OracleClient classes and want to migrate to the new Oracle Data Provider for .Net.

Thanks

There is no real difference in how they are used, unless you are doing weird stuff with In/Out parameters or cursors.

The difference that you would see in your code is that the namespace will change to Oracle.DataAccess . I believe that most of the type-names stayed the same.

Your code might look as any standard ADO.NET code and you will be using an OracleConnection :

var connectionString = "Data Source=ORCL;User Id=user;Password=pwd;";

using (var conn = new OracleConnection(connectionString))
using (var cmd = conn.CreateCommand())
{
    conn.Open(); 
    cmd.CommandText = "SELECT name FROM mytable";
    using (var reader = cmd.ExecuteReader())
    {
        while (reader.Read())
        {
            string name = reader.GetString(0);
            // TODO: process the results here
        }
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM