SQL Statement in vb.net app is returning unexpected results.

Posted on 2006-05-19
Medium Priority
Last Modified: 2010-04-23
I am using a vb.net console app to transfer data to/from an asp.net site. I am using the following to create a dataset. I have tried Xferstatus as an integer and as text, but do not get any records returned.

The number of records returned is 0, although there are two records that meet the criteria. If I drop the 'Where" clause, all records are returned. If I run the statement from Enterprise Manager, I get the correct records returned.

Here is the complete statement:
        Dim dsRequests As New DataSet
        Dim da As New SqlDataAdapter(cmdSQL)
        Dim newS As Integer = s - 1
        cmdSQL.CommandText = "SELECT * FROM WorkRequests WHERE XferStatus = 0;"

        Catch ex As Exception
            strLogMsg = "Error in GetRequests"
            strExceptMsg = ex.Message
            ReqError = True
            NoException = False

            If cmdSQL.Connection.State = ConnectionState.Open Then cmdSQL.Connection.Close()
        End Try

        If NoException Then
                If dsRequests.Tables(0).Rows.Count = 0 Then

In this case, count = 0 and it should be 2.
Question by:jberv534
LVL 96

Assisted Solution

by:Bob Learned
Bob Learned earned 75 total points
ID: 16723138
What is 'XferStatus' declared as in SQL Server?


Author Comment

ID: 16723154
I have set as both an integer and char. In the form you see, it is an integer.

Assisted Solution

maidinhtai earned 75 total points
ID: 16723232
I think the matter is the sql statement:  cmdSQL.CommandText = "SELECT * FROM WorkRequests WHERE XferStatus = 0"
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.


Assisted Solution

RJeyaPrakash earned 75 total points
ID: 16723310

i think there is no problem with the statement. Did u get the code working inside the block

If NoException Then
                If dsRequests.Tables(0).Rows.Count = 0 Then

Can u post yr complete code????
LVL 34

Accepted Solution

Sancler earned 150 total points
ID: 16724177
If I drop the 'Where" clause, all records are returned.

What happens with

        cmdSQL.CommandText = "SELECT * FROM WorkRequests WHERE XferStatus <> 0;"

Does it return all records?  Or no records?  Or all records except those where XferStatus = 0?


Author Comment

ID: 16724901
Thank you all for the help. It turns-out, and I hate to admit this, but it was strictly my problem in controlling the application.

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone 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

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses

755 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