最近有在做一个需求,需要在VB6.0中调用存储过程,整理了一下,供大家参考,
范例:
1 Function callStoredProcedure(sEmployeeID As String, Optional sNotes As String = "") As String 2 On Error GoTo errHand 3 Dim conn As ADODB.Connection 4 Set conn = "driver={SQL Server};server=(local);uid=sa;pwd=;database=pubs" 5 6 Dim adoComm As Object 7 Set adoComm = CreateObject("ADODB.Command") '创建一个对象,用来调用存储过程 8 With adoComm 9 .ActiveConnection = conn '设置连接 10 .CommandType = 4 '类型为存储过程,adCmdStoredProc = 4 11 .CommandText = "dbo.SP_BIG_CASE_REPORT" '存储过程名称 12 '.Parameters.Item("存储过程中参数的名称").Value = “值” 13 .Parameters.Item("@EmployeeID").Value = sEmployeeID '设置输入参数 14 .Parameters.Item("@Notes").Value = sNotes 15 .Execute '执行存储过程 16 End With 17 Set conn = Nothing 18 19 Exit Function 20 errHand: 21 MsgBox "callStoredProcedure Error : " & Err.Description, vbOKOnly + vbCritical, sApplicName 22 End Function
如果您看了本篇博客,觉得对您有所收获,请点击右下角的 [推荐]
如果您想转载本博客,请注明出处
如果您对本文有意见或者建议,欢迎留言
感谢您的阅读,请关注我的后续博客