asp.net 从数据库存储过程执行两次sql 返回两个table(也就是两次数据) 然后程序里用dataset 接收 然后dataset的 tables[1]有值,tables[0]怎么没有 但是table 已经被创建了 就是没有值 但是我执行存储过程 是有值的啊
程序 DataSet ds = SqlHelper.ConSelect(SqlHelper.ConnectionStringHy, "Hy_getcostselect", para);
public static DataSet ConSelect(string connstr, string proc, SqlParameter[] para)
{ using (SqlConnection conn = new SqlConnection())
{
conn.ConnectionString = connstr;
if (conn.State == ConnectionState.Closed)
{
conn.Open();
}
using (SqlCommand comm = new SqlCommand())
{
comm.Connection = conn;
comm.CommandType = CommandType.StoredProcedure;
comm.CommandText = proc;
foreach (SqlParameter sp in para)
{
comm.Parameters.Add(sp);
}
SqlDataAdapter da = new SqlDataAdapter();
da.SelectCommand = comm;
DataSet ds = new DataSet();
da.Fill(ds);
return ds;
}
} }
存储过程:
set @sqlstr=N' select max(ces.autoid) as autoid,max(ces.缴费单据编号) as payNumber,max(ces.缴费项目) payItem,sum(ces.缴费单价) as payPrice,sum(ces.应交费用) as yingJiao,sum(ces.实际缴费) as shiJiao,max(ces.费用所属时间) as Stime from HYFORHT.dbo.charge_EditSubordinate ces
where ces.缴费项目 in('+@nameID+') and ces.缴费单据编号= '+char(39)+@Jcode+char(39)+' and 费用所属时间='+char(39)+@fytime+char(39)+ ' group by ces.缴费项目'
execute sp_executesql @sqlstr set @sqlstr=N'select 楼盘编号 as bh,室号 as sh from HYFORHT.dbo.房产基本信息 where 房产编号='+char(39)+@FCnumber+char(39)
execute sp_executesql @sqlstr
并且两条器语句有数据返回 第二条就能接收到
感觉程序应该没什么,因为我用一条普通的sql语句的时候 程序就能接收到值
程序 DataSet ds = SqlHelper.ConSelect(SqlHelper.ConnectionStringHy, "Hy_getcostselect", para);
public static DataSet ConSelect(string connstr, string proc, SqlParameter[] para)
{ using (SqlConnection conn = new SqlConnection())
{
conn.ConnectionString = connstr;
if (conn.State == ConnectionState.Closed)
{
conn.Open();
}
using (SqlCommand comm = new SqlCommand())
{
comm.Connection = conn;
comm.CommandType = CommandType.StoredProcedure;
comm.CommandText = proc;
foreach (SqlParameter sp in para)
{
comm.Parameters.Add(sp);
}
SqlDataAdapter da = new SqlDataAdapter();
da.SelectCommand = comm;
DataSet ds = new DataSet();
da.Fill(ds);
return ds;
}
} }
存储过程:
set @sqlstr=N' select max(ces.autoid) as autoid,max(ces.缴费单据编号) as payNumber,max(ces.缴费项目) payItem,sum(ces.缴费单价) as payPrice,sum(ces.应交费用) as yingJiao,sum(ces.实际缴费) as shiJiao,max(ces.费用所属时间) as Stime from HYFORHT.dbo.charge_EditSubordinate ces
where ces.缴费项目 in('+@nameID+') and ces.缴费单据编号= '+char(39)+@Jcode+char(39)+' and 费用所属时间='+char(39)+@fytime+char(39)+ ' group by ces.缴费项目'
execute sp_executesql @sqlstr set @sqlstr=N'select 楼盘编号 as bh,室号 as sh from HYFORHT.dbo.房产基本信息 where 房产编号='+char(39)+@FCnumber+char(39)
execute sp_executesql @sqlstr
并且两条器语句有数据返回 第二条就能接收到
感觉程序应该没什么,因为我用一条普通的sql语句的时候 程序就能接收到值
解决方案 »
- c# 如何做到拖曳图片框到其它的软件上,并获得相对应的句柄。
- c#遍历Excel中的数据什么方式最快?
- 不能添加其键已在使用中的实体
- 项目解决方案中的“引用”,是代码中的using是什么关系呀?
- winform问题 如下
- 07年了 工作也要快一年了,我想在软件方面考点证,我是国企的,请问靠什么好一点阿
- 事件(event)是不是都应该有个onEvent方法
- 请教数据存储方案
- 网络程序?!
- 数值类型转换问题,(欢迎回帖)
- Response.Write("<script>alert(\"请输入试验重量!\")</script>"); 无法弹出对话框
- 寻c# c/s数据同步方案,客户端access服务器端sqlserver2005
execute Hy_getcostselect @strtime='2012-01-01',
@endtime='2012-01-31',
@WhereFY='电费,水费,',
@FCnumber='FC1109280001',
@mytype='1'
能够查询出来数据 然后我用程序调用的 报语法错误 ,难道是 用sql查询分析器调用的 跟 c#调用的 存储过程 会有不同sql语句产生sql profiler 怎么用啊 用sql profiler能够看到c#所执行的存储过程?