110,896
社区成员
发帖
与我相关
我的任务
分享
不知道问题出在哪里,请大佬指正。
断点看是有数据的,rtn=5
public DataSet rgs_data_query()
{
SqlParameter[] sps = new SqlParameter[]
{
new SqlParameter("@item","10-1402"),
new SqlParameter("@indate","2023-05-16")
};
try
{
DataSet Ds = new DataSet();
Ds = DBInfo.GetDataSet("dbo.s_wcf_test1", sps);
return Ds;
}
catch (Exception ex)
{
return null;
}
}
public static DataSet GetDataSet(string procName, params SqlParameter[] parameters)
{
DataSet Ds = new DataSet();
try
{
int rtn = 0;
MyConnection = new SqlConnection(MyConnectionString);
SqlCommand cmd = new SqlCommand();
cmd.Connection = MyConnection;
cmd.CommandText = procName;
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddRange(parameters);
SqlDataAdapter sda = new SqlDataAdapter(cmd);
sda.Fill(Ds);
DataTable Dt = new DataTable();
rtn = sda.Fill(Dt);
if (MyConnection.State == ConnectionState.Open)
{
MyConnection.Close();
MyConnection.Dispose();
}
return Ds;
}
catch (SqlException ex)
{
if (MyConnection.State == ConnectionState.Open)
{
MyConnection.Close();
MyConnection.Dispose();
}
return null;
}
finally
{
MyConnection.Close();
MyConnection.Dispose();
}
}