English 中文(简体)
最好用...... NET和Oracle [封闭]
原标题:The best way to read SQL Query using .NET and Oracle [closed]

我怎么能从结构分类的计算中得到结果?

有两个案件”

CASE 1
 RETURN "Process ok"
CASE 2
 RETURN "Process failed"

This will be returned from the stored procedure.

怎样才能在www.net、C#(Windows Forms)上阅读?

最佳回答

如果您认为可以取得多个记录或<代码>,请您使用<代码>DataReader。 缩略语 如果你只获得单一价值,没有记录,没有多个栏目,只是一个插头或暗中......

在这里,如何使用储存程序,然后让读者阅读第1栏:

using(var  conn = new OracleConnection("Data Source=oracledb;User Id=UserID;Password=Password;"))
{
    OracleCommand cmd = new OracleCommand();
    cmd.Connection = conn;
    cmd.CommandText = "storedProcedurename";
    cmd.CommandType = CommandType.StoredProcedure;

    cmd.Parameters.Add(...);

    conn.Open();
    OracleDataReader dr = cmd.ExecuteReader();

    while(dr.Read())
    {
        var yourResult = dr[0].ToString();
    }
}
问题回答

这取决于你是否正在援引所储存的程序,或者如果你试图收回记录。

关于所储存的程序,它可以将数值分配到<代码>>out <>>>或inout参数或生成一个记录。 前者需要使用command.CommandType至

典型的问题是:

using (var cmd = connection.CreateCommand())
{
    cmd.CommandText = "SELECT something FROM YourTable";
    using (var reader = cmd.ExecuteReader())
    {
        while (reader.Read())
        {
            Console.WriteLine(reader["something"]);
        }
    }

}

关于数据库链接,我确实建议你使用





相关问题
Manually implementing high performance algorithms in .NET

As a learning experience I recently tried implementing Quicksort with 3 way partitioning in C#. Apart from needing to add an extra range check on the left/right variables before the recursive call, ...

Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

How do I compare two decimals to 10 decimal places?

I m using decimal type (.net), and I want to see if two numbers are equal. But I only want to be accurate to 10 decimal places. For example take these three numbers. I want them all to be equal. 0....

Exception practices when creating a SynchronizationContext?

I m creating an STA version of the SynchronizationContext for use in Windows Workflow 4.0. I m wondering what to do about exceptions when Post-ing callbacks. The SynchronizationContext can be used ...

Show running instance in single instance application

I am building an application with C#. I managed to turn this into a single instance application by checking if the same process is already running. Process[] pname = Process.GetProcessesByName("...

How to combine DataTrigger and EventTrigger?

NOTE I have asked the related question (with an accepted answer): How to combine DataTrigger and Trigger? I think I need to combine an EventTrigger and a DataTrigger to achieve what I m after: when ...

热门标签