Link to home
Start Free TrialLog in
Avatar of rwallacej
rwallacej

asked on

Adapter returns nothing

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
Avatar of Nasir Razzaq
Nasir Razzaq
Flag of United Kingdom of Great Britain and Northern Ireland image

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
Avatar of rwallacej
rwallacej

ASKER

thanks, yes I appreciate you can use this, however using the table adapter so there is "intellisense"
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.
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
ASKER CERTIFIED SOLUTION
Avatar of Nash2334
Nash2334

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial