日期:2014-05-16 浏览次数:20879 次
public static void OpenDB()
{
if (_oleConnection.State != ConnectionState.Open)
{
_oleConnection.Open();
}
}
public static void CloseDB()
{
if (_oleConnection.State != ConnectionState.Closed)
{
_oleConnection.Close();
}
}
public static void SaveControl(List <SmartControlData> list)
{
string strSqlUpdate = "update SMT_Control_Table set PreviousID=?, NextID=? where ID=?;";
OpenDB();
for (int i = 0; i < 1300; i++)
{
SmartControlData Folder = list[i];
OleDbParameter[] parameters = new OleDbParameter[3];
parameters[0] = new OleDbParameter("PreviousID", OleDbType.VarChar, 50);
if (Folder.PreviousID == null)
{
Folder.PreviousID = "";
}
parameters[0].Value = Folder.PreviousID;
parameters[1] = new OleDbParameter("NextID", OleDbType.VarChar, 50);
if (Folder.NextID == null)
{
Folder.NextID = "";
}
parameters[1].Value = Folder.NextID;
parameters[2] = new OleDbParameter("ID", OleDbType.VarChar, 50);
parameters[2].Value = Folder.ID;
//OpenDB();
OleDbCommand cmd = _oleConnection.CreateCommand();
cmd.CommandText = strSqlUpdate;
OleDbTransaction transaction = _oleConnection.BeginTransaction();
cmd.Transaction = transaction;
cmd.Parameters.Add(parameters[0]);
cmd.Parameters.Add(parameters[1]);
cmd.Parameters.Add(parameters[2]);
cmd.Exe