public static DataSet ExecuteDataset(OleDbConnection connection, CommandType commandType, string commandText, params OleDbParameter[] commandParameters)
        {
            if (connection == null) throw new ArgumentNullException("connection");            // Create a command and prepare it for execution
            OleDbCommand cmd = new OleDbCommand();
            bool mustCloseConnection = false;
            PrepareCommand(cmd, connection, (OleDbTransaction)null, commandType, commandText, commandParameters, out mustCloseConnection);            // Create the DataAdapter & DataSet
            using (OleDbDataAdapter da = new OleDbDataAdapter(cmd))
            {
                DataSet ds = new DataSet();                // Fill the DataSet using default values for DataTable names, etc
                da.Fill(ds);//fill的时候 提示newid未定义                // Detach the OleDbParameters from the command object, so they can be used again
                cmd.Parameters.Clear();                if (mustCloseConnection)
                    connection.Close();                // Return the dataset
                return ds;
            }        }
为什么呢?ps:谁有完整的sqlhelper for access 请给一份我 mikezzx#163.com

解决方案 »

  1.   

    //fill的时候 提示newid未定义问题不在这里吧,查看一下语句吧
      

  2.   

    newid() 是不是 表字段的默认值,类似于getdate(),access不支持就报错了。
      

  3.   

    數據庫是直接眾SQL里導到ACCESS的吧。。程序沒問題,去改你的數據庫,把你的標識欄,如Newid數據類型改成自動增加,因為你導過來,newsid被換成了整形,ACCESS整形不能自動遞增的,所以,你必須手動去改你的數據庫。正是因為newid沒有遞增,所以,你程序在增加數據時,newid為空,數據庫會報錯。