on 08-13-2004 3:08 AM
Hi All,
VB.Net
Can some provide a small sample of how to call a stored procedure and retrieve the returned result string using the SAPbobsCOM.Command object?
Regards Rayner
Hi,
Here is a sample of VB6 code for executing a SP:
<i>Private Sub Form_Load()
Dim lErr As Long
Dim sErr As String
Dim oRS As SAPbobsCOM.Recordset
Dim oCommend As SAPbobsCOM.Command
On Error GoTo Err_FormLoad
Set oComp = New SAPbobsCOM.Company
oComp.Server = "(Local)" '1 Server name
oComp.CompanyDB = "XXX" '2 Company name
oComp.DbUserName = "sa" '3 DBUsername
oComp.DbPassword = "" '4 DBPassword
oComp.UserName = "xxxxxxx" '5 Username
oComp.Password = "xxxxxxx" '6 Password
If Not oComp.Connect() = 0 Then Call Err.Raise(-999, "Form Load", "Error contecting to DB")
Set oRS = oComp.GetBusinessObject(BoRecordset)
Set oCommend = oRS.Command
oCommend.Name = "<Your Stored Procedure Name>"
oCommend.Parameters.Item(1).Value = 1
oCommend.Parameters.Item(2).Value = 60
oCommend.Execute '// call sub execute
'// get last error
oComp.GetLastError lErr, sErr
MsgBox lErr & " " & sErr
Exit_FormLoad:
'cleanup
Set oCommend = Nothing
Set oRS = Nothing
'retval
Exit Sub
Err_FormLoad:
Call oComp.GetLastError(lErr, sErr)
Call MsgBox("ERROR: " & lErr & " - " & sErr)
Resume Exit_FormLoad
End Sub</i>
HTH
Regards,
Yaniv G.
SDK Consultant,
SAP Manage Israel.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
96 | |
10 | |
9 | |
5 | |
3 | |
3 | |
3 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.