Database db = DatabaseFactory.CreateDatabase();
string sql = "SELECT * FROM table";
DbCommand cmd = db.GetSqlStringCommand(sql);//添加这句就不会出现错误
DataSet ds = db.ExecuteDataSet(cmd);
return ds;
转载于:https://www.cnblogs.com/lanyue52011/p/3444946.html