Database db = DatabaseFactory.CreateDatabase(); string sql = "SELECT * FROM table"; DbCommand cmd = db.GetSqlStringCommand(sql);//添加这句就不会出现错误 DataSet ds = db.ExecuteDataSet(cmd); return ds;