标签:style blog http io color ar os sp for
// Define the database query string mySelectQuery="SELECT Name, Sales FROM REPS;"; // 。。。。。。
// 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");
// Define the database query string mySelectQuery="SELECT * FROM REPS;"; // 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); myConnection.Open();
// set chart data source - the data source must implement IEnumerable chart1.DataSource = myCommand.ExecuteReader(CommandBehavior.CloseConnection); // Set series members names for the X and Y values chart1.Series["Series 1"].XValueMember = "Name"; chart1.Series["Series 1"].YValueMembers = "Sales"; // Data bind to the selected data source chart1.DataBind();
// Create a database reader OleDbDataReader myReader = myCommand.ExecuteReader(CommandBehavior.CloseConnection); // Since the reader implements and IEnumerable, pass the reader directly into // the DataBind method with the name of the Column selected in the query chart1.Series["Default"].Points.DataBindY(myReader, "GrossSales");
// Create a database reader OleDbDataReader myReader = myCommand.ExecuteReader(CommandBehavior.CloseConnection); // Since the reader implements IEnumerable, pass the reader directly into // the DataBind method with the name of the Column selected in the query chart1.Series["Default"].Points.DataBindXY(myReader, "Name", myReader, "Sales");
标签:style blog http io color ar os sp for
原文地址:http://www.cnblogs.com/pengzhen/p/4082435.html