看一下小弟我写的SqlHelper,好像有异常
看一下我写的SqlHelper,好像有错误
二楼上代码
------论坛禁止夹带广告,如再发现,就直接封杀了-----
------解决方案--------------------
第二个方法的返回类型直接改成DataSet,然后return返回值只留dataset,去掉.Tables[0]就可以了。
------解决方案--------------------
SqlParameter[] parameters //参数化数组
params 加上之后就可以在不需要这个参数的时候直接不写。不加的话要写null
------解决方案--------------------
再加一个
二楼上代码
------论坛禁止夹带广告,如再发现,就直接封杀了-----
------解决方案--------------------
第二个方法的返回类型直接改成DataSet,然后return返回值只留dataset,去掉.Tables[0]就可以了。
------解决方案--------------------
SqlParameter[] parameters //参数化数组
params 加上之后就可以在不需要这个参数的时候直接不写。不加的话要写null
------解决方案--------------------
再加一个
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;
}