运行此代码大约40秒后,在表格中插入约400条记录,我得到了
OleDbException未处理 - 未指定错误。
代码的副本:
clsDBConnector dbConnector = new clsDBConnector();
OleDbDataReader dr;
string sqlStr;
dbConnector.Connect();
sqlStr = " SELECT MAX(EventID) AS MaxID" +
" FROM Events";
dr = dbConnector.DoSQL(sqlStr);
while (dr.Read())
{
EventID = Convert.ToInt16( dr[0].ToString());
}
dr.Close();
sqlStr = " SELECT MemberID" +
" FROM GroupMembers" +
" WHERE (GroupID = " + GroupID + ")";
dr = dbConnector.DoSQL(sqlStr);
while (dr.Read())
{
MemberID = Convert.ToInt16( dr[0].ToString());
clsDBConnector dbConnectorInsert = new clsDBConnector();
string cmdStr = "INSERT INTO EventsAtendees " +
"(MemberID, EventID) " +
"VALUES (" + MemberID + ", " + EventID + ")";
dbConnectorInsert.Connect();
dbConnectorInsert.DoDML(cmdStr);
dbConnectorInsert.close();
}
dr.Close();
我已经取出了自定义字段和变量,以使每个人都更有用。