How to Call Sql Server Stored Procedure in VB6

Hello Guys, At this time i will show to you on how to execute or call a stored procedure of
SQL Sever, here we go>>>>>>>>>>

Make sure that your Database Connection and Command, like shown at code below



Public MrCmd As ADODB.Command 'just put it on amodule
Public Conn As ADODB.Connection

i declare MrCmd as my ADODB.Command and Conn As ADODB.Connection as
Public for me to access or use it every-time i want, so you can write it like this

Set MrCmd = New ADODB.Command ' you must set MrCmd  as New 
                                                               ADODB.Command
MrCmd.ActiveConnection = Conn          ' this were your connection is being set
MrCmd.CommandType = adCmdStoredProc 'since we are dealing with stored procedure
                                                                 'let set the command type = adCmdStoredProc

MrCmd.CommandText = "Get_Products" ' this is your Stored Procedure

MrCmd.Execute 'execute your stored procedure
MrCmd.ActiveConnection = Nothing 'set your connection  close

Hope this will help

Happy Coding
The Hardest Thing to Do is to Do Nothing ^_^
These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • Furl
  • Reddit
  • Spurl
  • StumbleUpon
  • Technorati

Leave a comment

Copyright @ Codes-47.Blogspot.Com. Powered by Blogger.