看一下我写的SqlHelper,好像有错误
本帖最后由 caozhy 于 2014-01-02 13:12:32 编辑 二楼上代码
------论坛禁止夹带广告,如再发现,就直接封杀了-----
[解决办法]
第二个方法的返回类型直接改成DataSet,然后return返回值只留dataset,去掉.Tables[0]就可以了。
[解决办法]
public static DataSet ExecuteDataset(SqlConnection connection, CommandType commandType, string commandText, params SqlParameter[] commandParameters)
{
//create a command and prepare it for execution
SqlCommand cmd = new SqlCommand();
PrepareCommand(cmd, connection, (SqlTransaction)null, commandType, commandText, commandParameters);
//create the DataAdapter & DataSet
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
//fill the DataSet using default values for DataTable names, etc.
da.Fill(ds);
// detach the SqlParameters from the command object, so they can be used again.
cmd.Parameters.Clear();
//return the dataset
return ds;
}