Learn how to a build a cloud-first strategyRegister Now


Adapter returns nothing

Posted on 2011-04-26
Medium Priority
Last Modified: 2012-08-14

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
Question by:rwallacej
  • 2
  • 2
LVL 83

Expert Comment

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

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


Author Comment

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

Expert Comment

ID: 35468368
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 Comment

ID: 35468541
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
LVL 10

Accepted Solution

Nash2334 earned 2000 total points
ID: 35469231
Are you sure the parameters that you are sending into the preview window are the same as those that you are sending in the actual code?  Code will help.

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
Suggested Courses
Course of the Month20 days, 18 hours left to enroll

810 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