在C#中VS2010中数据库的动态绑定

我必须使用动态数据源创建图表,我有一个代码。 它不显示错误,但图形在运行时也不可见。

这里out_table是我的表的名称,ADX是其列之一。

码:

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

谢谢你的帮助。 我已经解决了这个问题,而对于其他人来说,这就是解决方案。 这里,ds是数据集

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