深圳全飞鸿
标题:
VB调用mysql数据库存储过程SP的方法
[打印本页]
作者:
zhgc
时间:
2019-5-4 13:23
标题:
VB调用mysql数据库存储过程SP的方法
本帖最后由 zhgc 于 2019-6-25 10:19 编辑
VB调用mysql数据库SP的方法
VB调用mysql数据库SP的方法
http://www.nagomes.com/disc/foru ... ad&tid=22&fromuid=6
VB对mysql的SQL增删改查
http://www.nagomes.com/disc/foru ... d&tid=109&fromuid=6
Public cn As ADODB.Connection
Dim spcmd As New Command
c_ReturnMessage = "ERROR"
spcmd.ActiveConnection = cn
If spcmd.Parameters.Count = 0 Then
spcmd.Parameters.Append spcmd.CreateParameter("@x", adVarChar, adParamOutput, 200, "")
End If
spcmd.CommandType = adCmdText
spcmd.CommandText = "call SMT.G_SCADA_I1PORT_KB('" & data & "','" & gw28_list(c_gw28_index).station_no & "',@x)"
spcmd.Execute
Set rs = cn.Execute("select @x")
If Not rs.EOF Then
c_ReturnMessage = rs(0).Value
End If
rs.Close
Set rs = Nothing
复制代码
作者:
zhgc
时间:
2019-5-4 16:57
以上方法并不是真正在调用SP, 请参考以下方法:
Public Function callsp(Mydata As String, gw28index) As String
Dim strsql As String
Dim rs As Recordset
Dim sp As String
Dim call_sp As ADODB.Command
If gw_list(gwindex).sp = "" Then
callsp = "SCADA CONFIG ERROR"
Exit Function
End If
Set call_sp = New ADODB.Command
With call_sp
.ActiveConnection = cn
.CommandType = adCmdStoredProc
.CommandText = gw_list(gwindex).sp
.Parameters(0) = Mydata
.Parameters(1) = gw_list(gwindex).line_name
.Parameters(2) = gw_list(gwindex).station_name
.Execute
callsp = .Parameters(3)
End With
End Function
复制代码
欢迎光临 深圳全飞鸿 (http://www.nagomes.com/disc/)
Powered by Discuz! X3.2