OleDbException未处理 - 一分钟后崩溃

时间:2017-02-03 13:19:47

标签: c# sql access dml

运行此代码大约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();

我已经取出了自定义字段和变量,以使每个人都更有用。

0 个答案:

没有答案