vb.net调用存储过程

CREATEPROCEDUREALL_USERINFO@upidint,@nintasdeclare@strvarchar(200)set@str='selecttop'... CREATE PROCEDURE ALL_USERINFO
@upid int,
@n int
as
declare @str varchar(200)
set @str='select top '+@n+' id,name from hunli where upid=@upid order by id desc'
exec(@str)
GO

-----------------------存储过程 --------------------------------

Public Function selectall(ByVal n As Integer, ByVal upid As Integer) As DataSet
Dim sql As String = "ALL_USERINFO"
Dim conn As SqlConnection = connection(connstr)
Dim cmd As SqlCommand = New SqlCommand(sql, conn)

addsqlparamer(cmd, m_userinfo.dbparam_upid, SqlDbType.Int, upid)
addsqlparamer(cmd, "@n", SqlDbType.Int, n)
Dim sda As SqlDataAdapter = New SqlDataAdapter(cmd)
Dim ds As New DataSet
Try
conn.Open()
sda.Fill(ds, "hunli")
Return ds
Catch ex As Exception
Finally
cmdclose(cmd)
connclose(conn)
End Try
'

End Function

Public Sub addsqlparamer(ByRef cmd As SqlCommand, ByVal dbparam As String, ByVal dbtype As SqlDbType, ByVal value As Object)
cmd.CommandType = CommandType.StoredProcedure

Dim sqlparam As SqlParameter = New SqlParameter(dbparam, dbtype)
sqlparam.Value = value
cmd.Parameters.Add(sqlparam)
End Sub

Public Function selectall(ByVal n As Integer, ByVal upid As Integer) As DataSet
Return sqluserinfo.selectall(n, upid)
End Function

Private Sub userinfodatabind(ByVal n As Integer, ByVal upid As Integer)
Dim ds As New DataSet

Dim blluserinfo As DLL.d_userinfo = New DLL.d_userinfo
ds = blluserinfo.selectall(n, upid)

Me.getuserinfo.DataSource = ds
Me.getuserinfo.DataBind()

End Sub

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
userinfodatabind(2, 3)

End Sub
这段存储过程用三层架构调用的,, 执行后不报错 但是执行后为空白
展开
 我来答
著名医生陈国良
2009-11-18 · TA获得超过1125个赞
知道小有建树答主
回答量:484
采纳率:0%
帮助的人:557万
展开全部
m_userinfo.dbparam_upid是什么,前后都没有提到
应该是“@upid”吧,你不是在设置参数吗。
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式