会员
周边
众包
新闻
博问
闪存
所有博客
当前博客
我的博客
我的园子
账号设置
简洁模式
...
退出登录
注册
登录
滨_Notepad
学习工作点滴积累
博客园
::
首页
::
新随笔
::
联系
::
订阅
::
管理
公告
在.net中接收存储过程返回的值
Posted on
2007-12-10 20:38
新人~
阅读(
416
) 评论(
0
)
编辑
收藏
举报
SqlParameter[] par = new SqlParameter[2]; par[0] = new SqlParameter("@id", SqlDbType.Int); par[0].Value = id; par[1] = new SqlParameter("@count", SqlDbType.Int); par[1].Direction = ParameterDirection.Output; //设置为输出参数
getCon();
//
连接数据库的方法
int
id
=
35
;
SqlParameter[] par
=
new
SqlParameter[
2
];
par[
0
]
=
new
SqlParameter(
"
@id
"
, SqlDbType.Int);
par[
0
].Value
=
id;
par[
1
]
=
new
SqlParameter(
"
@count
"
, SqlDbType.Int);
par[
1
].Direction
=
ParameterDirection.Output;
//
设置为输出参数
SqlHelper.ExecuteNonQuery(con, CommandType.StoredProcedure,
"
getChildCount
"
, par);
this
.Label1.Text
=
par[
1
].Value.ToString();
//
接收输出的参数
存储过程代码如下:
create
proc
getChildCount
@id
int
,
@count
int
output
as
select
@count
=
babycount
from
yangsCMS_Article_Class
where
id
=
@id
order
by
treekey
会员力量,点亮园子希望
刷新页面
返回顶部
Powered by:
博客园
Copyright © 2024 新人~
Powered by .NET 8.0 on Kubernetes