Solved

Using a Table Adapter - Passing an output parameter

Posted on 2011-03-02
4
1,182 Views
Last Modified: 2012-06-27
I created a stored procedure that takes in three parameter and returns and OUTPUT parameter which is an Integer. (No columns... just the output parameter)

How can I user a Table Adapter to return the Integer Output parameters value?

My code (below) errors stating that a DataTable can not be converted to an integer.

How do I do fix this?
 
Public Function GetPickTicketID(ByVal ComponentID As String, ByVal Inventory As String, ByVal ClientID As String) As Integer
        Dim intRecordID As Integer = IDAdapter.GetPickTicketID(ComponentID, Inventory, ClientID)
    End Function

Open in new window

tableadapter.png
0
Comment
Question by:cdemott33
[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
  • 2
4 Comments
 
LVL 52

Expert Comment

by:Carl Tawn
ID: 35021733
Assuming ClientID is your OUTPUT parameter, try:
Dim intRecordID As Nullable(Of Integer) = 0
IDAdapter.GetPickTicketID(1, 2, intRecordID)

Open in new window

0
 

Author Comment

by:cdemott33
ID: 35021941
How to I return the value the GetPickTicketID method?

I can pass the intRecordID value into the method as you've instructed but how do I get the returned value from my method?  If I attempt to return the IDAdapter method I still get an error of  "DataTable can not be converted to an integer."

In other words, when I call the GetPickTicketID TableAdaptor method it should pass back (Via the Output parameter) a single integer value.  Something like 1 or 23 or 456.  My function need to return whatever that value is.

Please advise.
0
 
LVL 52

Accepted Solution

by:
Carl Tawn earned 500 total points
ID: 35021974
OUTPUT parameters from stored procedures are represented as ByRef parameters to the method call. So if you put you code as per my last post the OUTPUT parameters value will be written to the "intRecordID" variable, which you can then return from your method.
0
 

Author Closing Comment

by:cdemott33
ID: 35022059
Thank you, thank you , THANK YOU!  Perfect!  Your help was great appreciated.
0

Featured Post

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Question has a verified solution.

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

Suggested Solutions

Introduction: When running hybrid database environments, you often need to query some data from a remote db of any type, while being connected to your MS SQL Server database. Problems start when you try to combine that with some "user input" pass…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

740 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