记下来以备后用折腾了一个小时郁闷至极
string sql = "insert into keys ([key],[count],[IsCollection],[flot],[IsOver],[fid]) values (@key,@count,@IsCollection,@flot,@IsOver,@fid)";
try
{
conn.Open();
try
{
// conn.BeginTransaction();
foreach (KeyInfo key in keyList)
{
if (ExistsKey(key.Key))
{
AddCount(key.Key);
}
else
{
conn.ExecuteNonQuery(sql, new System.Data.OleDb.OleDbParameter[]{new System.Data.OleDb.OleDbParameter("@key",key.Key),
new System.Data.OleDb.OleDbParameter("@count",key.Count),
new System.Data.OleDb.OleDbParameter("@IsCollection",key.IsCollect),
new System.Data.OleDb.OleDbParameter("@flot",key.Floor),
new System.Data.OleDb.OleDbParameter("@IsOver",key.IsOver),
new System.Data.OleDb.OleDbParameter("@fid",key.FID)});
}
}
// conn.Commit();
}
catch(Exception ex)
{
// throw (ex);
// conn.Rollback();
}
在System.Data.oleDb 命名空间下使用SQL语句插入内容要在字段名与表名加“[]”