Solved

Accessing Stored Procedure Parameters (Sequel Server 2002) from VB6

Posted on 2003-10-22
8
245 Views
Last Modified: 2010-04-17
I have problems reading my OUTPUT parameters from Stored Procedures as well as passing an input value into it from VB6.
0
Comment
Question by:ManiKing
8 Comments
 
LVL 43

Expert Comment

by:TimCottee
ID: 9597910
Hi ManiKing,

Can you show the code you are currently trying to use and then we can suggest how to resolve the problem.

Tim Cottee MCSD, MCDBA, CPIM
Brainbench MVP for Visual Basic
http://www.brainbench.com
0
 
LVL 4

Accepted Solution

by:
Sandeepk1999 earned 43 total points
ID: 9617854
Make sure you are passing the parameters in right order and have used exact parameter names in your code.
0
 
LVL 1

Assisted Solution

by:Junior_Pete
Junior_Pete earned 41 total points
ID: 9620327
If you are using an ADODB.Command object try the following

'Setup the command object as normal without the parameters.

oCmd.ActiveConnection = conn
oCmd.CommandTimeout = 45
oCmd.CommandType = adStoredProcedure
oCmd.CommandText = "Stored Procedure name here"

'Then instead of manually adding the parameters do this

oCmd.Refresh  ' or oCmd.Parameters.Refresh (cant quite remember which one)

'This should collect the params from the database

CMD.Execute

Dim StrOutput as string

strOutput = cmd.Parameters("@OutputParameterNameHere").Value

Try that and see if it works

Let us know if it doesnt!!

Peter
0
 
LVL 1

Assisted Solution

by:mahesh_mp
mahesh_mp earned 41 total points
ID: 9640909
hello maniking
this is a simple code for paramete for stored proc

  Dim cmd As New Command
  Dim strFirstArg As New Parameter
  Dim intSecondArg As New Parameter
 
  cmd.CommandText = "yourProcedure"
  cmd.CommandType = adCmdStoredProc
 
  Set strFirstArg = cmd.CreateParameter("PrimaryKey", adVarChar, adParamInput, 10)
  Set intSecondArg = cmd.CreateParameter("PrimaryKey", adInteger, adParamInput, 4)
 
  cmd.Parameters.Append strFirstArg
  cmd.Parameters.Append intSecondArg
 
  strFirstArg.Value = 1 your arguments
  intSecondArg.Value = 2 your arguments
 
  cmd.ActiveConnection = dbConn
'set your recorset  rsTemp

  Set rsTemp = cmd.Execute
0
 

Author Comment

by:ManiKing
ID: 9655929
Thanx guys.
I eventually resolved it.
Later.
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
This is about my first experience with programming Arduino.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now