简体   繁体   English

以图形方式显示Oracle SQL表中的数据

[英]Displaying data from a oracle sql table graphically

I have programmatically created a chart using ASP.Net, now I just need to figure out how to connect to an oracle sql developer database and retrieve the data to populate the chart. 我已经使用ASP.Net通过编程方式创建了一个图表,现​​在我只需要弄清楚如何连接到oracle sql developer数据库并检索数据以填充图表即可。

Would I use an OleDb method (see below), along with some other logic? 我会使用OleDb方法(见下文)以及其他一些逻辑吗?

      using System.Data.OleDb;
      OleDbConnection myConnection = new OleDbConnection;();
      myConnection.ConnectionString = myConnectionString;
      myConnection.Open();
      //execute queries, etc
      myConnection.Close();

Any help would be great. 任何帮助都会很棒。

http://justins-fat-tire.blogspot.com/ http://justins-fat-tire.blogspot.com/

I've got some code examples that show how to use a stored procedure to fill a dataset/table and get a generic List of object data. 我有一些代码示例,展示了如何使用存储过程填充数据集/表并获取对象数据的通用列表。 If you're using raw sql you will need to modify the command object a bit. 如果您使用的是原始sql,则需要稍微修改命令对象。

You would use a DataTable as the data source for the chart. 您将使用DataTable作为图表的数据源。 To do this, you first need to populate the table. 为此,您首先需要填充表格。

public void Populate()
{
    Datatable data = GetData();

    foreach(DataRow r in data.Rows)
    {
        /// Populate chart using data
    }
}

public DataTable GetData()
{
    try
    {
    OleDbConnection myConnection = new OleDbConnection;();
    myConnection.ConnectionString = myConnectionString;
    myConnection.Open();

    OleDbCommand myCommand = myConnection.CreateCommand();

    //Set commandtype and text here.
    myCommand.CommandType = SOMETYPE;
    myCommand.CommandText = "SOMETEXT";

    OleDbDataReader reader = myCommand.ExecuteReader();

    DataTable t = new DataTable();
    t.Load(reader);

    return t;
    }
    catch (Exception e)
    {
        throw e;
    }
    finally
    {
        myConnection.Close();
    }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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