Top DevX Stories
Creating Custom Export Filters for StarOffice with XSLT
WPF Wonders: Using DataTemplates
Crystal Reports Family Offers Options for Developers
Avaya Aura Session Manager video
Avaya Aura Overview video
Search the forums:

Go Back   DevX.com Forums > DevX Developer Forums > Database

Reply
 
Thread Tools Search this Thread Rate Thread Display Modes
  #1  
Old 11-18-2004, 01:33 AM
mallli_ mallli_ is offline
Registered User
 
Join Date: Nov 2004
Location: singapore
Posts: 2
Executing SQL Server stored procedure from vb6

Hi all,

Can anyone help me provide the code as to how to Execute a SQL Server stored procedure with a parameter from vb6.

Thanks
Reply With Quote
  #2  
Old 11-18-2004, 03:14 AM
Phil Weber Phil Weber is offline
Super Moderator
 
Join Date: Nov 2003
Location: Portland, OR
Posts: 8,171
http://www.freevbcode.com/ShowCode.Asp?ID=3687
__________________
Phil Weber
http://www.philweber.com

Please post questions to the forums, where others may benefit.
I do not offer free assistance by e-mail. Thank you!
Reply With Quote
  #3  
Old 11-18-2004, 03:26 AM
mallli_ mallli_ is offline
Registered User
 
Join Date: Nov 2004
Location: singapore
Posts: 2
Executing SQL Server stored procedure from vb6

Hi Weber,

Thanks for your reply. Actually I need to pass a parameter to the stored procedure. For example, in sql server the stored procedure is executed as exec test '200410' .

I have been trying this code
Private Sub Form_Load()
Dim con As New ADODB.Connection
Dim stmt, parm As String
Dim rs As New ADODB.Recordset
con.ConnectionTimeout = 100


con.Open "northwind", "userid", "password"

parm = "200410"

stmt = " test '" & parm & "'"
rs.Open stmt, con, adOpenStatic, adLockReadOnly, adCmdStoredProc
If rs.STATE = adStateOpen Then rs.Close
If con.STATE = adStateOpen Then con.Close
Set rs = Nothing
Set con = Nothing


End Sub


It throws an error [Microsoft][ODBC Sql Server Driver] Syntax error or access violation.

Please help as to where the statement is failing.

Thnks & Rgds,
Mallik
Reply With Quote
  #4  
Old 11-18-2004, 09:50 AM
pclement's Avatar
pclement pclement is offline
Moderator
 
Join Date: Dec 2003
Posts: 2,750
See if the following helps:

Calling a Stored Procedure with a Command
__________________
Paul
~~~~
Microsoft MVP (Visual Basic)
Reply With Quote
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT -4. The time now is 12:23 AM.


Sponsored Links



Acceptable Use Policy

internet.comMediabistrojusttechjobs.comGraphics.com

WebMediaBrands Corporate Info


Advertise | Newsletters | Feedback | Submit News

Legal Notices | Licensing | Permissions | Privacy Policy


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.