Solved

Why does this DataTable have no data in it?

Posted on 2014-07-17
8
132 Views
Last Modified: 2014-07-19
Hello,

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
MsgBox(myCustomers.Rows.Count)

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
MsgBox(myInvoices.Rows.Count)

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!

Thanks,
Jason
TblInvoices.png
TblCustomers.png
0
Comment
Question by:SqueezeOJ
  • 4
  • 2
  • 2
8 Comments
 

Author Comment

by:SqueezeOJ
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.
0
 
LVL 14

Expert Comment

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

Author Comment

by:SqueezeOJ
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!
0
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 40204165
Can you show us code from your Form_Load event?
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:SqueezeOJ
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

0
 
LVL 83

Accepted Solution

by:
CodeCruiser earned 250 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.
0
 
LVL 14

Assisted Solution

by:quizwedge
quizwedge earned 250 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.
0
 

Author Closing Comment

by:SqueezeOJ
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.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Concerto provides fully managed cloud services and the expertise to provide an easy and reliable route to the cloud. Our best-in-class solutions help you address the toughest IT challenges, find new efficiencies and deliver the best application expe…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

930 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

12 Experts available now in Live!

Get 1:1 Help Now