引入oledb类库
private OleDbConnection _oleDbConn;
//Adapter对象
private OleDbDataAdapter _oleDbAda;
//连接串 包括oledb版本和mdb路径
_oleDbConn = new OleDbConnection(tring_strdata);//根据链接信息实例化链接对象
_oleDbConn.Open();//打开连接;
string sql = "select * from coininfo where source='Okcoin'";
OleDbCommand aCommand = new OleDbCommand(sql, _oleDbConn);
OleDbDataReader dr= aCommand.ExecuteReader();
//OleDbDataReader遍历读取
while (reader.Read())
{
var t1 = reader["字段名"];
}
//插入操作:
string sql = "insert into kline([source],[cointype],[ticks],[datetime],[open],[High],[Low],[close],[Volume])"+
" values('okcoincn','ltc_cny','" + ticks + "','2017-8-31 12:23:12','" +open + "','" + high + "','" + low +
using System.Data.OleDb;
private OleDbConnection _oleDbConn;
//Adapter对象
private OleDbDataAdapter _oleDbAda;
//连接串 包括oledb版本和mdb路径
private String tring_strdata = @"provider=microsoft.jet.oledb.4.0; Data Source=d:\itm\axydeal.mdb";
具体操作:
//实例化、打开连接、读取数据_oleDbConn = new OleDbConnection(tring_strdata);//根据链接信息实例化链接对象
_oleDbConn.Open();//打开连接;
string sql = "select * from coininfo where source='Okcoin'";
OleDbCommand aCommand = new OleDbCommand(sql, _oleDbConn);
OleDbDataReader dr= aCommand.ExecuteReader();
//OleDbDataReader遍历读取
while (reader.Read())
{
var t1 = reader["字段名"];
}
//插入操作:
string sql = "insert into kline([source],[cointype],[ticks],[datetime],[open],[High],[Low],[close],[Volume])"+
" values('okcoincn','ltc_cny','" + ticks + "','2017-8-31 12:23:12','" +open + "','" + high + "','" + low +
"','" + close + "','" + volume + "')";
OleDbCommand aCommand = new OleDbCommand(sql, _oleDbConn);
aCommand.ExecuteNonQuery();