string connString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
SqlConnection objConnection = new SqlConnection(connString);
objConnection.Open(); SqlCommand strSQL = new SqlCommand("UP_ReceiptBankView_search", objConnection);
strSQL.CommandType = CommandType.StoredProcedure; SqlParameter FId = strSQL.Parameters.Add("@FId", SqlDbType.Int);
FId.Value = Convert.ToInt32(DDLFiliale.Text);
FId.Direction = ParameterDirection.Input; SqlParameter StartTime = strSQL.Parameters.Add("@StartTime", SqlDbType.DateTime);
StartTime.Value = Convert.ToDateTime(TBStartTime.Text);
StartTime.Direction = ParameterDirection.Input; SqlParameter EndTime = strSQL.Parameters.Add("@EndTime", SqlDbType.DateTime);
EndTime.Value = Convert.ToDateTime(TBEndTime.Text);
EndTime.Direction = ParameterDirection.Input;
SqlParameter HValue = strSQL.Parameters.Add("@HValue", SqlDbType.Int, 32);
HValue.Direction = ParameterDirection.Output; SqlDataReader objDataReader = strSQL.ExecuteReader(CommandBehavior.CloseConnection); GridView1.Visible = true;
PTotal.Visible = true;
int abc;
abc=Convert.ToInt32(strSQL.Parameters["@HValue"].Value) ; Response.Write(abc);
//LBTotal.Text = abc;
this.GridView1.AllowSorting = false;
this.GridView1.AllowPaging = false;
GridView1.DataSource = objDataReader;
GridView1.DataBind(); objConnection.Close();
USE [Excellent8]
GO
/****** 对象: StoredProcedure [dbo].[UP_ReceiptBankView_search] 脚本日期: 02/12/2009 11:03:53 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[UP_ReceiptBankView_search]@FID int,
@StartTime datetime,
@EndTime datetime,
@HValue int outputas
set @HValue=(select sum(RMB) as HValue1
from [ReceiptBankView] where (Time1 between @StartTime and @EndTime) and (FID=@FID ) and (win=1)
GROUP BY Fid )select * from [ReceiptBankView] where (Time1 between @StartTime and @EndTime) and (FID=@FID ) and (win=1) ORDER BY [Time1] DESC
go
解决方案 »
- ASP.NET的又一个问题!
- 梅花雪等高手们请进来看一眼吧,实在搞不定了
- Infragistics 控件加载树的问题
- 请教关于repeater中使用HyperLink的问题
- 在微软官方网站下的WebControls,300多k的。但安装后没有Microsoft.Web.UI.WebControls.dll,怎么解决这个问题??
- 怎么样让程序在页面请求时自动给页面加上<meta>信息?
- 如何取得某月的某一天距離月底的天數?
- .NET2003的问题
- 怎么样在datagrid中设置超级连接,也就是说在属性的url中怎么样设置才能带数据库的字段作为参数?
- 那里有水晶报表9.0可以下?
- 请问怎样得到超链接传递的参数?谢谢。
- 运行时候 web.config 报错···怎么回事呢··??
from [ReceiptBankView] where (Time1 between @StartTime and @EndTime) and (FID=@FID ) and (win=1)
GROUP BY Fid
这个单独运行一下,看看是什么东西
你把上面那一行换成abc=HValue.value 再试一次。。
from [ReceiptBankView] where (Time1 between @StartTime and @EndTime) and (FID=@FID ) and (win=1)
GROUP BY Fid )
from [ReceiptBankView] where (Time1 between @StartTime and @EndTime) and (FID=@FID ) and (win=1)
GROUP BY Fid )这样子 写 @HValue的值 是 ()里面的select子句的 返回值
这样子写
select @HValue=sum(RMB)
from [ReceiptBankView] where (Time1 between @StartTime and @EndTime) and (FID=@FID ) and (win=1)
GROUP BY Fid )
用ExecuteNonQuery();
但是计算的合计值出来不了~!
你可以按照6楼说的,先试一下。
SqlParameter HValue = strSQL.Parameters.Add("@HValue", SqlDbType.Int, 32);
HValue.Direction = ParameterDirection.Output;
("@HValue", >>("HValue",
PTotal.Visible = true;
int abc;
// abc=Convert.ToInt32(strSQL.Parameters["@HValue"].Value) ; // 此时 objDataReader 还没 close 是无法访问到 output param 的 //Response.Write(abc);
//LBTotal.Text = abc;
this.GridView1.AllowSorting = false;
this.GridView1.AllowPaging = false;
GridView1.DataSource = objDataReader;
GridView1.DataBind(); objDataReader.Close();
abc=Convert.ToInt32(strSQL.Parameters["@HValue"].Value) ; // 此时 objDataReader 已 close
Response.Write(abc);
的方法是对的
我刚测试过了
也非常感谢dolphin683 的热情
谢谢大家,问题已解决
结贴了