当我的程序运行时,以下错误不断弹出。对此很新,所以我不知道如何去捕捉这个......做了一个快速搜索alrd,但似乎没有任何帮助。
以下是我的代码的一部分:
protected DBBase(string tableName, string primary_key)
{
string s = Application.StartupPath + "\\alliancedb.accdb";
conn = new OleDbConnection(String.Format("Provider=Microsoft.ACE.OLEDB.12.0; Data Source={0}", s));
if (conn.State == ConnectionState.Closed)
{
conn.Open();
dataset = new DataSet();
//query statement
string sqlStatement = String.Format("Select * from {0} order by {1} ASC", tableName, primary_key);
//run sql
DBadpt = new OleDbDataAdapter(sqlStatement, conn);
oOrderDetailsCmdBuilder = new OleDbCommandBuilder(DBadpt);
DBadpt.Fill(dataset);
dbTab = dataset.Tables[0];
dbTab.TableName = this.tableName = tableName;
rows = dbTab.Rows;
}
else if (conn.State == ConnectionState.Open)
{
conn.Close();
conn.Open();
dataset = new DataSet();
//query statement
string sqlStatement = String.Format("Select * from {0} order by {1} ASC", tableName, primary_key);
//run sql
DBadpt = new OleDbDataAdapter(sqlStatement, conn);
oOrderDetailsCmdBuilder = new OleDbCommandBuilder(DBadpt);
DBadpt.Fill(dataset);
dbTab = dataset.Tables[0];
dbTab.TableName = this.tableName = tableName;
rows = dbTab.Rows;
}
}