473,394 Members | 1,785 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

query returns Dataset table rows count 1 with no data in the table

I am loading a datagriview with data in the tables.
Below is the code I used.

Expand|Select|Wrap|Line Numbers
  1. Dim da As SqlDataAdapter
  2.         Try
  3.             ds = New DataSet
  4.             da = New SqlDataAdapter("select A.ANALCODE 'ANALYSIS CODE ID',B.ANALCODEDESC 'ANALYSIS CODE DESC' from ACT00052_P A,ACT00051_P B where B.ANALCODE = A.ANALCODE and A.SACCTCOMB = '" & cmbAccount.Text & "' order by A.ANALCODE", sqlCon1)
  5.             ds.Clear()
  6.             da.Fill(ds, "ConnToSqlDrp")
  7.             If ds Is Nothing = True Then
  8.                 DGV2.Rows.Clear()
  9.                 Exit Sub
  10.             Else
  11.                 da.Fill(ds)
  12.                 DGV2.DataSource = ds.Tables(0)
  13.             End If
  14.         Catch ex As Exception
  15.             MsgBox(ex.Message.ToString())
  16.         End Try
There is no data in the table but ds is Nothing is going False and the control is moved to else part of the program.
I am using VS 2012.Please help me.
Sep 17 '13 #1
1 1380
zmbd
5,501 Expert Mod 4TB
ds Is Nothing
You've set da = New SqlDataAdapter("select A.ANALCODE 'ANALYSIS CODE ID'(...)
(I am guessing the "DA" should be "DS" - yes?)
So ofcourse your code is branching to the false statement as written because ds Is Nothing is checking the object "DS" and not the values contained therein (even if you have the "DA"/"DS" thing correct, then "DS" was set to a new object in line 3).

You need to be checking for the records in the data source/table.

Someone a little more versed than I in dot-net is going to have to help you with that method.
Sep 17 '13 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Kevin Myers | last post by:
Hello, I'm an experienced application developer in some languages (including various SQL dialects), but have very little experience with MS Access or VBA, and am having trouble figuring out how...
1
by: HB | last post by:
I have an application that is requiring me to pull 4 tables into a dataset then perfom the final query to display on the page Dim objODBCAdapter As New Data.Odbc.OdbcDataAdapter("SELECT...
1
by: Maxwell2006 | last post by:
Hi, I am working with strongly typed datatables. What is the most efficient way to build a new DataTAble based on the result of DataTable.Select? At this point I use a foreach loop to do the...
2
by: gurusshetty | last post by:
Hi Please help me in finding out no. of rows in data table inside dataset using c# thanks guru
2
by: kalyanilovesme | last post by:
Hi I have a html table.. and i am adding the table rows dynamically... actually table rows are 64.. but according to the program some are visible and other are invisible.. i want to calculate...
7
by: kunku | last post by:
Hi, I am using a query "Select SUM(Amount) from tblAccount where TransactionID=' "+textBox1.Text+" ' "; in my C# project this query return dataset.Tables.Rows.Count =1 eventhough there...
2
by: kveerareddy | last post by:
How can i get the total rows of a table: If i use "select count(*) from <tablename>" it will take lot of time to get the total row count. for example in MSSQL we have "SELECT ROWS FROM...
0
by: krisssgopi | last post by:
Hi Team, While am using the below code it was throwing an exception update unable to find table mapping or data table customer. Please help me in this regard. Private Sub Button1_Click(ByVal...
2
EntryTeam
by: EntryTeam | last post by:
Count is about 67k, while phisycally there are only 2 records returned by query. What's going on? The cycle keeps returning those two records until exception or change in cycle condition. for...
1
HaLo2FrEeEk
by: HaLo2FrEeEk | last post by:
I've got a table where I store tips for a challenge. Its structure is this: tip_id, challenge_id, user_id, ip_address, tip_date, tip_text The tips can be voted up or down, I store vote data in...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.