Created
December 19, 2012 19:12
-
-
Save cofearabi/4339565 to your computer and use it in GitHub Desktop.
(C#) display the chart extracting from Access mdb database of stock data
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void display_chart(int code , int miniY) | |
{ | |
chart1.ChartAreas[0].AxisY.Minimum = miniY; | |
String meigara = code.ToString(); | |
// Resolve the address to the Access database | |
// string fileNameString = @"stock_mdb.mdb"; | |
string fileNameString = @"c:\mdb\stock_mdb.mdb"; | |
// Initialize a connection string | |
string myConnectionString = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=" + fileNameString; | |
// Define the database query | |
string mySelectQuery = "SELECT * FROM table_stock where meigara='" + meigara + "' order by hiduke;"; | |
// 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[0].XValueMember = "hiduke"; | |
chart1.Series[0].YValueMembers = "evalue"; | |
chart1.Series[0].ChartType = SeriesChartType.Line; | |
chart1.Series[1].XValueMember = "hiduke"; | |
chart1.Series[1].YValueMembers = "hvalue"; | |
chart1.Series[1].ChartType = SeriesChartType.Line; | |
// Data bind to the selected data source | |
//chart1.DataBind(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment