1
我得到這個異常:C#NotSupportedException異常是未處理DATABINDTABLE
chart1.DataBindTable(myReader, "Name");
這裏; S的完整代碼:
// Access database
//System.Windows.Forms.DataVisualization.Charting.Utilities.SampleMain.MainForm mainForm = (System.Windows.Forms.DataVisualization.Charting.Utilities.SampleMain.MainForm)this.ParentForm;
//string fileNameString = "\\data\\chartdata.mdb";
// Initialize a connection string
string myConnectionString = "Provider=SQLOLEDB;Data Source=hermes;Initial Catalog=qcvaluestest;Integrated Security=SSPI;";
// Define the database query
string mySelectQuery = "SELECT name, finalconc from qvalues where rowid in (20365,20366,20367);";
// Create a database connection object using the connection string
OleDbConnection myConnection = new OleDbConnection(myConnectionString);
// Create a database command on the connection using query
OleDbCommand myCommand = new OleDbCommand(mySelectQuery, myConnection);
// Open the connection
myCommand.Connection.Open();
// Create a database reader
OleDbDataReader myReader = myCommand.ExecuteReader(CommandBehavior.CloseConnection);
// Since the reader implements and IEnumerable, pass the reader directly into
// the DataBindTable method with the name of the Column to be used as the XValue
chart1.DataBindTable(myReader, "Name");
// Close the reader and the connection
myReader.Close();
myConnection.Close();
我到底做錯了什麼?我知道它應該連接。也許sql語句不返回任何東西?
,什麼是chart1? – 2010-11-02 16:51:50
它的MSChart。 。 。 – 2010-11-02 16:52:06