VB 调用SQL SERVER 存储过程
我在SQL的GS数据库里有一个GPDM表,,表里有GPDM(字符)和GPCN(字符)两个字段,已建立一个AA过程createprocedureAAasbeginselec...
我在SQL 的GS 数据库里有一个GPDM 表,,表里有GPDM(字符) 和GPCN(字符) 两个字段, 已建立一个AA过程
create procedure AA
as
begin
select * from GPDM
end
求各位大神给一段完整的VB 6 的联接代码
能在MSGBOX 显示记录数 展开
create procedure AA
as
begin
select * from GPDM
end
求各位大神给一段完整的VB 6 的联接代码
能在MSGBOX 显示记录数 展开
- 你的回答被采纳后将获得:
- 系统奖励15(财富值+成长值)+难题奖励30(财富值+成长值)
1个回答
展开全部
'引用Microsoft ActiveX Data Objects 2.8 Library
Dim Cnn As ADODB.Connection
Dim Rs As ADODB.Recordset
Dim Cnn_c As New ADODB.Command
Dim cnn_p As ADODB.Parameter
Set Cnn = New ADODB.Connection
Set Rs = New ADODB.Recordset
'On Error Resume Next
Cnn.ConnectionString = ConnStr '连接字符串
With Cnn
.CursorLocation = adUseClient
.Open '连接
End With
Set Cnn_c.ActiveConnection = Cnn
With Cnn_c
.CommandType = adCmdStoredProc '命令类型:存储过程
.CommandText = "AA" '存储过程名
End With
Set cnn_p = Cnn_c.CreateParameter("ReTurn", adInteger, adParamReturnValue)
Cnn_c.Parameters.Append cnn_p '添加参数ReTurn(返回值)
Set Rs = Cnn_c.Execute '执行
MsgBox Rs.RecordCount '显示记录数
If Rs.RecordCount > 0 Then
Rs.Close
End If
Cnn.Close
Set cnn_p = Nothing
Set Cnn_c = Nothing
Set Rs = Nothing
Set Cnn = Nothing
Dim Cnn As ADODB.Connection
Dim Rs As ADODB.Recordset
Dim Cnn_c As New ADODB.Command
Dim cnn_p As ADODB.Parameter
Set Cnn = New ADODB.Connection
Set Rs = New ADODB.Recordset
'On Error Resume Next
Cnn.ConnectionString = ConnStr '连接字符串
With Cnn
.CursorLocation = adUseClient
.Open '连接
End With
Set Cnn_c.ActiveConnection = Cnn
With Cnn_c
.CommandType = adCmdStoredProc '命令类型:存储过程
.CommandText = "AA" '存储过程名
End With
Set cnn_p = Cnn_c.CreateParameter("ReTurn", adInteger, adParamReturnValue)
Cnn_c.Parameters.Append cnn_p '添加参数ReTurn(返回值)
Set Rs = Cnn_c.Execute '执行
MsgBox Rs.RecordCount '显示记录数
If Rs.RecordCount > 0 Then
Rs.Close
End If
Cnn.Close
Set cnn_p = Nothing
Set Cnn_c = Nothing
Set Rs = Nothing
Set Cnn = Nothing
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |