Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to call procedure in VB 6

Status
Not open for further replies.

sparkme

Programmer
Oct 3, 2003
30
US

Helo,
I'am learning VB 6,Can someone tell me how to call
sql server stored procedure with TWO input parameters
like @Name ,@DOB , After making database connections?

Also if you can suggect me a real good book to learn myself VB 6 (Project oriented)thatwould be great.

THANKS IN ADVANCE!

....Sparkme
 
What data connection objects are you using, ADO? Do you want to return a recordset to your app? if both are yes try something like this,

Code:
Dim rs As ADODB.Recordset
Dim cmd As ADODB.Command

Set rs = New ADODB.Recordset
Set cmd = New ADODB.Command
With cmd
   .ActiveConnection = CONN
   .CommandType = adCmdStoredProc
   .CommandText = "sprBalanceCredits"
   .Parameters.Append .CreateParameter("P1", adInteger, adParamInput)
   .Parameters("P1").value = "value"
   .Parameters.Append .CreateParameter("P2", adInteger, adParamInput)
   .Parameters("P2").value = "value"
End With
rs.Open cmd, , adOpenStatic, adLockOptimistic
If Not rs.BOF And Not rs.EOF Then 
  ...whatever...
End If
rs.Close
Set rs = Nothing
Set cmd = Nothing

Remember to change your parameter names and feed the correct values, check your parameter types (both are integer in the example). This assumes that the connection object (CONN) is open and of larger scope.


Take Care,

zemp

"If the grass looks greener... it's probably because there is more manure."
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top