简体   繁体   中英

dynamic binding of chart from database in VS2010 in C#

I have to create charts with dynamic datasource, I have a code. It does not show error but the graph is also not visible on runtime.

Here out_table is the name of my table and ADX is one of its column.

code:

OleDbConnection con1 = new OleDbConnection(@"PROVIDER=Microsoft.ACE.OLEDB.12.0;DATA SOURCE=RS.accdb");
String sqlo = "Select ADX from " + out_table + "";
OleDbCommand myCommand = new OleDbCommand(sqlo, con1);
myCommand.Connection.Open();
OleDbDataReader myreader = myCommand.ExecuteReader(CommandBehavior.CloseConnection);
chart1.DataBindTable(myreader, "ADX"); 

thanks for helping me. I have solved this problem, and for others, here is the solution. here, ds is dataset

       OleDbConnection con1 = new OleDbConnection(@"PROVIDER=Microsoft.ACE.OLEDB.12.0;DATA SOURCE=RS.accdb");
         String sqlo = "Select * from " + out_table + "";
        OleDbDataAdapter da1 = new OleDbDataAdapter(sqlo, con);
        DataSet ds = new DataSet();
        da1.Fill(ds, in_table);
        DataView firstView = new DataView(ds.Tables[0]);
        chart1.Series[0].Points.DataBindXY(firstView, "ID", firstView, "ADX");

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