Dynamically linking a chart from a database in VS2010 in C #

I need to create charts with dynamic data source, I have some code. It doesn't show an error, but the graph doesn't show at runtime either.

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

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"); 

      

+3


source to share


1 answer


Thanks for helping me. I 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");

      

+2


source







All Articles