我用下面的这段代码想从一个表中筛选出一部分字段再添加到另一个表中做个备份,可是总是备份到一半的时候出现了错误,要备份的记录有108条,可总是备份到63条是出现错误,我想会不会是Connect Timeout的默认值是15秒太少了呢,请大家帮我看一下,谢谢了!!!!!!
-----------------------------------------------------------------------------------------
private void Button4_Click(object sender, System.EventArgs e)
{
string myConn2 = ConfigurationSettings.AppSettings["connection"];
string mySQLstr2 = "select Account,balance,now() as DelDate from AccountList where Account in (select AccountID from AccountLog a where CreateDate=(select max(CreateDate) from AccountLog where AccountID=a.AccountID) and CreateDate+int(CurrBalance) < now() and int(Income) > 0);";
OleDbConnection myConnection2 = new OleDbConnection(myConn2);
OleDbCommand myCommand2 = new OleDbCommand(mySQLstr2, myConnection2);
//myCommand2.Connection.Open();
myConnection2.Open();
OleDbDataReader myReader =myCommand2.ExecuteReader();
while(myReader.Read())
{
string Acc = myReader.GetInt32(0).ToString();
string Bal = myReader.GetValue(1).ToString();
string DelDate = myReader.GetValue(2).ToString();
string myConn3 = ConfigurationSettings.AppSettings["connection"];
string insertSQLstr3 = "insert into AccountList_bak (Account_bak,Balance_bak,DelDate) values ('"+Acc+"','"+Bal+"','"+DelDate+"')"; OleDbConnection myConnection3 = new OleDbConnection(myConn3);
OleDbCommand myCommand3 = new OleDbCommand(insertSQLstr3, myConnection3);
//myCommand3.Connection.Open();
myConnection3.Open();
myCommand3.ExecuteNonQuery();
}
myConnection2.Close();
} 出现的错误信息为:
-----------------------------------------------------------------------------------------
未指定的错误
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 异常详细信息: System.Data.OleDb.OleDbException: 未指定的错误源错误: 行 134: OleDbCommand myCommand3 = new OleDbCommand(insertSQLstr3, myConnection3);
行 135: //myCommand3.Connection.Open();
行 136: myConnection3.Open();
行 137: myCommand3.ExecuteNonQuery();
行 138:
-----------------------------------------------------------------------------------------
private void Button4_Click(object sender, System.EventArgs e)
{
string myConn2 = ConfigurationSettings.AppSettings["connection"];
string mySQLstr2 = "select Account,balance,now() as DelDate from AccountList where Account in (select AccountID from AccountLog a where CreateDate=(select max(CreateDate) from AccountLog where AccountID=a.AccountID) and CreateDate+int(CurrBalance) < now() and int(Income) > 0);";
OleDbConnection myConnection2 = new OleDbConnection(myConn2);
OleDbCommand myCommand2 = new OleDbCommand(mySQLstr2, myConnection2);
//myCommand2.Connection.Open();
myConnection2.Open();
OleDbDataReader myReader =myCommand2.ExecuteReader();
while(myReader.Read())
{
string Acc = myReader.GetInt32(0).ToString();
string Bal = myReader.GetValue(1).ToString();
string DelDate = myReader.GetValue(2).ToString();
string myConn3 = ConfigurationSettings.AppSettings["connection"];
string insertSQLstr3 = "insert into AccountList_bak (Account_bak,Balance_bak,DelDate) values ('"+Acc+"','"+Bal+"','"+DelDate+"')"; OleDbConnection myConnection3 = new OleDbConnection(myConn3);
OleDbCommand myCommand3 = new OleDbCommand(insertSQLstr3, myConnection3);
//myCommand3.Connection.Open();
myConnection3.Open();
myCommand3.ExecuteNonQuery();
}
myConnection2.Close();
} 出现的错误信息为:
-----------------------------------------------------------------------------------------
未指定的错误
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 异常详细信息: System.Data.OleDb.OleDbException: 未指定的错误源错误: 行 134: OleDbCommand myCommand3 = new OleDbCommand(insertSQLstr3, myConnection3);
行 135: //myCommand3.Connection.Open();
行 136: myConnection3.Open();
行 137: myCommand3.ExecuteNonQuery();
行 138:
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货