1.创建数据库和表
http://blog.csdn.net/xiaobai1593/article/details/7053096
2.OLE类型数据的存储和读取(附件试了插入记录会出错-insert 不能查询多值字段)
插入
OleDbConnection conn = new OleDbConnection(strCnn);
string inserString = "insert into 01_01_张三 (timeRec,dataRec) values (@timeRec,@dataRec)";
OleDbCommand inst = new OleDbCommand(inserString, conn);
System.Data.OleDb.OleDbParameter paramTime = new OleDbParameter("@timeRec", System.Data.OleDb.OleDbType.Double);
paramTime.Value = DateTime.Now.ToOADate();
inst.Parameters.Add(paramTime);
System.Data.OleDb.OleDbParameter paramData = new OleDbParameter("@dataRec", System.Data.OleDb.OleDbType.Binary);
paramData.Value =data;
inst.Parameters.Add(paramData);
读取
strExcel = "select * from 01_01_张三";
OleDbDataAdapter myCommand = null;
myCommand = new OleDbDataAdapter(strExcel, strConn);
myCommand.Fill(ds, "dtSource");
dt = ds.Tables[0];
for (int i = 0; i < dt.Rows.Count; i++)
{
double time = (double)dt.Rows[i][0];
if (!DBNull.Value.Equals(dt.Rows[i][1]))
{
byte[] tempdata = (byte[])dt.Rows[i][1];
}
}