# Re: 请问vb6 ADO object Call SQL Server7.0 之stored procedures可行否,程式如何写????

Posted by nothing on October 11, 1999 at 09:41:07:

In Reply to: 请问vb6 ADO object Call SQL Server7.0 之stored procedures可行否,程式如何写???? posted by 皮皮 on October 08, 1999 at 16:15:01:

Private Sub Command1_Click(Index As Integer)
SQLHeadVariableString = "execute ProcAcDayCountPrint[" & mType & "],[" & _
MO_TranDate(Text1(0).Text) + "000" & "],[" & MO_TranDate(Text1(1).Text) + "999" & "],[" & mCreateInf & "]"
MO_ExecuAdoCom (SQLHeadVariableString)
End Sub

--这段我写成模组--
Sub MO_ExecuAdoCom(CommandString As String) '执行ado的查询命令
On Error GoTo ExecuAdoComError
Dim Cmd As ADODB.Command
Set Cmd = New ADODB.Command
With Cmd
Set .ActiveConnection = AccountConnection
.CommandText = CommandString
.CommandTimeout = 3600
.Execute
End With
Set Cmd = Nothing
Exit Sub
ExecuAdoComError:
Dim erritem As ADODB.Error
Dim msg As String
msg = Err.Number & ": " & Err.Description
MsgBox msg
For Each erritem In AccountConnection.Errors
msg = "Number: " & erritem.Number & vbCrLf & _
"Description: " & erritem.Description & vbCrLf & _
"Source: " & erritem.Source & vbCrLf & _
"NativeError: " & erritem.NativeError
MsgBox msg
Next
End Sub

我是这样用的.没有用odbc .. 你试试看..

Follow Ups: