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
using System; | |
using System.Collections.Generic; | |
using System.ComponentModel; | |
using System.Data; | |
using System.Drawing; | |
using System.Linq; | |
using System.Text; | |
using System.Windows.Forms; | |
using System.Windows.Forms.DataVisualization.Charting; | |
using System.Data.OleDb; | |
namespace WindowsFormsApplication1 | |
{ | |
public partial class Form1 : Form | |
{ | |
public Form1() | |
{ | |
InitializeComponent(); | |
} | |
private void Form1_Load(object sender, EventArgs e) | |
{ | |
// Full path to the data source file | |
string file = "6954.csv"; | |
string path = "\\mdb"; | |
// Create a connection string. | |
string ConStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+ | |
path+ ";Extended Properties=\"Text;HDR=No;FMT=Delimited\""; | |
OleDbConnection myConnection = new OleDbConnection(ConStr); | |
// Create a database command on the connection using query | |
string mySelectQuery = "Select * from "+ file; | |
OleDbCommand myCommand = new OleDbCommand(mySelectQuery, myConnection); | |
// Open the connection and create the reader | |
myCommand.Connection.Open(); | |
OleDbDataReader myReader = myCommand.ExecuteReader(CommandBehavior.CloseConnection); | |
// Column 1 is a time value, column 2 is a double | |
// databind the reader to the chart using the DataBindXY method | |
chart1.Series[0].Points.DataBindXY(myReader, "0", myReader, "2"); | |
chart1.Series[0].ChartType = SeriesChartType.Line; | |
//chart1.Series[0].ChartType = SeriesChartType.Stock; | |
// Close connection and data reader | |
myReader.Close(); | |
myConnection.Close(); | |
} | |
} | |
} |
0 件のコメント:
コメントを投稿