Why does this DataTable have no data in it?

Posted on 2014-07-17
Medium Priority
Last Modified: 2014-07-19

Using VS2013 to program a Windows Form application in VB.net.

Created DataSource which links to an Access mdb database:
Screenshot of VB.net Data SourceTbl_Customers has 8,670 records
Tbl_Invoices has 15,512 records

I can see these results using the Preview Data... function associated with each table in the Data Source.  See screenshots at end of post.

Write code to extract data from Tbl_Customers and it returns 8670.  PERFECT.  Code:
Dim myCustomers As DataTable = On_OrderDataSet.Tbl_Customers

Open in new window

Write duplicate code to extract data from Tbl_Invoices and it returns 0.  WRONG!  Code:
Dim myInvoices As DataTable = On_OrderDataSet.Tbl_Invoices

Open in new window

What the heck is going on?  Why won't this data come through?  Please help because it's driving me crazy!

Question by:SqueezeOJ
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
  • 2

Author Comment

ID: 40203349
I tried the exact same on four tables using slightly different syntax:
Dim myCategories As DataTable = On_OrderDataSet.Tables("Tbl_Categories")
MsgBox("Category Records = " & myCategories.Rows.Count)

Dim myCustomers As DataTable = On_OrderDataSet.Tables("Tbl_Customers")
MsgBox("Customer Records = " & myCustomers.Rows.Count)

Dim myFabrics As DataTable = On_OrderDataSet.Tables("Tbl_Fabrics")
MsgBox("Fabric Records = " & myFabrics.Rows.Count)

Dim myInvoices As DataTable = On_OrderDataSet.Tables("Tbl_Invoices")
MsgBox("Invoice Records = " & myInvoices.Rows.Count)

Open in new window

The ONLY one that worked correctly was the Customer table.
LVL 14

Expert Comment

ID: 40203471
How / when are you filling the tables with data? Is it after you're calling rows.count?

Author Comment

ID: 40203669
Good question and one I've been pondering.  I don't "fill" any of them, yet one is full of data and the other three are empty.  What statement would you recommend for me to fill them?  Thanks!
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.

LVL 83

Expert Comment

ID: 40204165
Can you show us code from your Form_Load event?

Author Comment

ID: 40204265
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

	' Adding Customer Columns
	lvwCustomers.Columns.Add("CustID", 100, HorizontalAlignment.Left)
	lvwCustomers.Columns.Add("Last", 150, HorizontalAlignment.Left)
	lvwCustomers.Columns.Add("First", 150, HorizontalAlignment.Left)
	lvwCustomers.Columns.Add("City", 150, HorizontalAlignment.Left)
	lvwCustomers.Columns.Add("Phone", 250, HorizontalAlignment.Left)

	' Adding Invoice Columns
	lvwInvoices.Columns.Add("InvID", 100, HorizontalAlignment.Left)
	lvwInvoices.Columns.Add("Created", 150, HorizontalAlignment.Left)
	lvwInvoices.Columns.Add("Status", 150, HorizontalAlignment.Left)
	lvwInvoices.Columns.Add("Sales Person", 250, HorizontalAlignment.Left)
	lvwInvoices.Columns.Add("Closed", 150, HorizontalAlignment.Left)

	Dim myCustomers As DataTable = On_OrderDataSet.Tables("Tbl_Customers")
	MsgBox("Customer Records = " & myCustomers.Rows.Count)

	Dim myInvoices As DataTable = On_OrderDataSet.Tables("Tbl_Invoices")
	MsgBox("Invoice Records = " & myInvoices.Rows.Count)

End Sub

Open in new window

LVL 83

Accepted Solution

CodeCruiser earned 1000 total points
ID: 40204312
There should be a Fill call on the On_OrderDataSet somewhere. Do a search within the form and within the solution to find where that is. There needs to be a similar fill call for the other datatables.
LVL 14

Assisted Solution

quizwedge earned 1000 total points
ID: 40205414
I'm referencing a previous question of yours that seems to be connected and may help us out: http://www.experts-exchange.com/Programming/Languages/.NET/Visual_Basic.NET/Q_28474839.html

It looks like you're not actually filling the tables using the fill command, but rather somehow through the Add -> Table Adapter wizard.

Check out http://msdn.microsoft.com/en-us/library/aa728893(v=vs.71).aspx You'll need to either add the additional queries to the Add -> Table Adapter wizard or you'll need to fill the dataset by doing something such as On_OrderDataSet.Fill(ds) where ds is your dataset.

Author Closing Comment

ID: 40206242
I found Me.Tbl_CustomersTableAdapter.Fill(Me.On_OrderDataSet.Tbl_Customers) hidden in the code.  Added additional ones ofr all other data tables and now it works great.  Thanks for helping me fix & understand the problem.

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

770 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