Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Moving data to and from Stored Procedures

Posted on 2006-06-14
3
Medium Priority
?
159 Views
Last Modified: 2010-04-30
I have just started working with Stored Proc's and have run into a problem that has me unsure what to do next. The original straight SQL mined what I wanted perfectly and now that I have placed it in a proc I cant get it to work. Any suggestions would be wonderful. Thank you.

**************Stored Proc*****************************************************
CREATE PROCEDURE SP_ExceptionCheck(
     @DateSelected datetime,
     @StoreNum bigint OUT,
     @Location varchar(50) OUT,
     @TrendarNum varchar(50) OUT)

AS
SET NOCOUNT ON

     SELECT StoreNum, Location, TrendarNum FROM Trendar
     WHERE TrendarNum NOT IN (SELECT TSID FROM C3DATA WHERE INVDTE = @DateSelected)
GO
*****************************************************************************
***************VB6 Code*******************************************************
Do Until DateSelected = (frmMain.dtpEndDate.Value + 1)

    Dim rsEx As ADODB.Recordset
    With cmd
        Set .ActiveConnection = cn
        .CommandText = "SP_ExceptionCheck"
        .CommandType = adCmdStoredProc
        Set params = .Parameters
    End With

    ' Define stored procedure params and append to command.
    params.Append cmd.CreateParameter("@WilcoStoreNum", adBigInt, adParamOutput, 0)
    params.Append cmd.CreateParameter("@Location", adVarChar, adParamOutput, 50)
    params.Append cmd.CreateParameter("@TrendarNum", adVarChar, adParamOutput, 50)
    params.Append cmd.CreateParameter("@DateSelected", adDBTimeStamp, adParamInput, 0)
   
    ' Specify input parameter values
    params("@DateSelected") = DateSelected
   
    ' Execute the command
    Set rsEx = cmd.Execute
   
    Dim CmdInsert As ADODB.Command
    Set CmdInsert = New ADODB.Command
    Set CmdInsert.ActiveConnection = conC3V
   
        With rsEx
            Do While Not rsEx.EOF
                CmdInsert.CommandText = "INSERT INTO Exceptions(WilcoStoreNum,Location,TrendarNum,ExcDate) " & _
                "Values ('" & rsEx![WilcoStoreNum] & "','" & rsEx![Location] & "','" & rsEx![TrendarNum] & "','" & DateSelected & "')"
                CmdInsert.Execute
                .MoveNext
            Loop
        End With
       
        rsEx.Close
        cn.Close
        DateSelected = (DateSelected + 1)
    Loop
************************************************************************************
The original SQL was:
rstDateExceptionCheck2.Open "SELECT WilcoStoreNum,Location,TrendarNum FROM Trendar " & _
'"WHERE TrendarNum NOT IN (SELECT TSID FROM C3DATA WHERE INVDTE = '" & DateSelected & "')", conC3V, adOpenKeyset, adLockOptimistic
************************************************************************************

The Error I'm getting states: Formal parameter '@DateSelected' was defined as OUTPUT but the actual parameter not declared OUTPUT.
0
Comment
Question by:edfreels
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 1

Author Comment

by:edfreels
ID: 16904745
Oh yeah, I did change this line :
params.Append cmd.CreateParameter("@DateSelected", adDBTimeStamp, adParamInput, 0)
 to adParamInputOutput but I still get the same error
0
 
LVL 66

Accepted Solution

by:
Jim Horn earned 500 total points
ID: 16904806
(wild guess)  I believe you have to do your Input parameters before your Output parameters.
0
 
LVL 1

Author Comment

by:edfreels
ID: 16904960
Thanks Jim, that did the trick. Talk about not paying attention!
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.

Question has a verified solution.

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

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses

670 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