Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old November 19th, 2003, 06:33 PM
Registered User
 
Join Date: Nov 2003
Location: , , United Kingdom.
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Calling Stored procedures with out parameters

I have an access 2000 adp project with an SQL 2000 backend server, I am trying to call a stored procedure with an input and output parameter. My store procedures look like this:

Alter Procedure prcCHK
    (
        @cuid as int,
        @pts as char(10) output
    )
As
select top 1 @pts=pts from tblp1 where custid=@cuid
return

my access procedure look like

   Dim CustomerID As Integer
   Dim pts As String
   CustomerID = 3065
   Set dblocal = CurrentProject.Connection
   dblocal.Execute ("prcCHK" & "'" & CustID & "' , '" & pts & "'")

All I want the code to do is call the stored procedure "prcCHK" and for it to return the a single value 'pts'

I have checked the syntax and it work fine outside of access (SQL Query Analyser) but does not when called from the access code. Any suggestions on how I can get the stored procedure to return a single value to the calling access procedure/function.

Reply With Quote
  #2 (permalink)  
Old November 25th, 2003, 04:30 PM
Registered User
 
Join Date: Nov 2003
Location: , MN, .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I had trouble with that too so I worked around it. I don't remember the order in which I discovered things but the first thing to try (if you haven't already) is add this line to your stored proc:
SET NOCOUNT ON

If that doesn't work, my work-around was to scrap the output parameter and instead have the last line of the proc be a select statement. Then in VBA open a recordset and grab that field.

Example:
In store proc last line is:
SELECT @RetMsg AS RetMsg


In Access:
        strSQL = "EXEC uspMySproc " & _
            Me!ItemVendorNumber

        Set cmd = New ADODB.Command
        With cmd
            .ActiveConnection = CurrentProject.Connection
            .CommandText = strSQL
            .CommandType = adCmdText
            .CommandTimeout = 2400
            Set rst = .Execute
        End With
        Set cmd = Nothing

        strStatus = Nz(rst.Fields("RetMsg"))

This has worked for me every time.
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Calling AS/400 Stored Procedures from VB.NET prasanthknair ADO.NET 0 January 19th, 2005 06:55 AM
Calling Oracle Stored Procedures booksnore2 General .NET 0 August 24th, 2004 02:08 PM
SQL Pass though parameters to stored procedures blinton25 SQL Server 2000 3 March 29th, 2004 02:49 PM
in-line parameters in stored procedures itekcorp ADO.NET 0 July 12th, 2003 09:57 PM



All times are GMT -4. The time now is 06:05 AM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.