Solved

Accessing Stored Procedure Parameters (Sequel Server 2002) from VB6

Posted on 2003-10-22
8
272 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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A short article about a problem I had getting the GPS LocationListener working.
Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
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 …

808 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