We help IT Professionals succeed at work.

Adapter returns nothing

Medium Priority
312 Views
Last Modified: 2012-08-14
Hi

I have simple stored procedure that returns True or False if a record exists in SQL

In the XSD viewer, the output of the stored procedure shows "Boolean 1" or "Boolean 0" for result. It is set to return type "Bit" and "Scalar"

However the TableAdapter always returns Nothing in the VB.net code

Ideas please to help, thanks in advance
Comment
Watch Question

CERTIFIED EXPERT
Most Valuable Expert 2012
Top Expert 2014

Commented:
Why would you use a table adapter to return a single value? That is overkill.

Dim dbcon as new SqlConnection("connection string")
dbcon.Open
Dim dbcmd As New SqlCommand("Select ...", dbcon)
Dim Exists As Boolean = dbcmd.ExecuteScalar()

dbcmd.Dispose
dbcon.Dispose

Author

Commented:
thanks, yes I appreciate you can use this, however using the table adapter so there is "intellisense"

Commented:
When configuring your table adapter, you will be prompted for whether to return a tabular value, single value or no value.  Depending on how your stored procedure is written, you need to make sure what is configured to return is correct in the wizard.  It sounds like you are executing a scalar query, in which case you will want to configure the table adapter to return a single value.  This will be of type object, so you will need to cast it to a boolean before checking the value.

Author

Commented:
hi, thanks, I've set this on the table adapter to return a value only;  in Visual Studio preview a result is shown but in code it is Nothing
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.