通过数据源控件建立调用的存储过程中的输出参数
dim sdsspbm as new sqldatasourcesdsspbm.ConnectionString = ConfigurationManager.ConnectionStrings("jxcConnectionString").ConnectionString
sdsspbm.SelectCommandType = SqlDataSourceCommandType.StoredProcedure
sds.SelectCommand = "proc_spzstj"
sdsspbm.SelectParameters.Add(New sqlparameter("@spzs", System.Type.GetType("sqldbtype.bigint")))
sdsspbm.SelectParameters("@spzs").Direction = Data.ParameterDirection.Output
lblmsg.Text = sdsspbm.SelectParameters("@spzs").ToString
存储过程如下:
CREATE PROC proc_spzstj @spzs bigint OUTPUT
AS
SELECT @spzs=count(spbm) FROM spbm
GO
目的:通过标签返回通过输出参数@spzs统计的记录数
错误:sdsspbm.SelectParameters.Add(New sqlparameter("@spzs", System.Type.GetType("sqldbtype.bigint")))
问题:如何通过数据源控件定义输出参数
--------------------编程问答-------------------- protected void SqlDataSource1_Selected(object sender, SqlDataSourceStatusEventArgs e)
{
IDbCommand cmd = e.Command;
SqlParameter a;
a= (SqlParameter)cmd.Parameters[""];
} --------------------编程问答-------------------- c#:
sdsspbm.SelectCommandType = SqlDataSourceCommandType.StoredProcedure;
sdsspbm.SelectCommand = "proc_spzstj";
sdsspbm.SelectParameters.Add("spzs", TypeCode.Int64, "");
sdsspbm.SelectParameters["spzs"].Direction = ParameterDirection.Output;
获得返回数,在SqlDataSource的Selected事件中:
protected void sdsspbm_Selected(object sender, SqlDataSourceStatusEventArgs e)
{
lblmsg.Text = e.Command.Parameters[0].Value.ToString();
}
补充:.NET技术 , ASP.NET