Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 285
  • Last Modified:

Accessing Stored Procedure Parameters (Sequel Server 2002) from VB6

I have problems reading my OUTPUT parameters from Stored Procedures as well as passing an input value into it from VB6.
0
ManiKing
Asked:
ManiKing
3 Solutions
 
TimCotteeCommented:
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
 
Sandeepk1999Commented:
Make sure you are passing the parameters in right order and have used exact parameter names in your code.
0
 
Junior_PeteCommented:
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
 
mahesh_mpCommented:
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
 
ManiKingAuthor Commented:
Thanx guys.
I eventually resolved it.
Later.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now