Adapter returns nothing

Posted on 2011-04-26
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 code

Ideas please to help, thanks in advance
Question by:rwallacej
    LVL 83

    Expert Comment

    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

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

    Expert Comment

    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

    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

    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

    Why You Should Analyze Threat Actor TTPs

    After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

    Join & Write a Comment

    Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
    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…
    Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
    This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor ( If you're looking for how to monitor bandwidth using netflow or packet s…

    754 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

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now