Solved

Null Values in Datatable - VB.Net

Posted on 2016-08-07
3
43 Views
Last Modified: 2016-08-09
Hello everyone,
So I am getting a weird anomaly while using a datatable in vb.net. Every so often I get nulls in my datatable where they do not exist in SQL. I know "how" to compensate for them, but that isn't my issue, they should not be there, and it just makes the integrity of results bad..

I am using the following code to populate the table
            Try
                Using Processing_LoadData As New SqlDataAdapter("SELECT [TrackingID],[SAMAccountName],[DisplayName],[givenName],[middleName],[sn],[employeeNumber],[employeeID],[EmployeeType],[Personal_Phone],[Personal_EMail],[roomNumber],[accountExpires],[Creator],[Location_Friendly],[LocationID],[Building_DN],[Address1],[Address2],[City],[State],[Zip],[Description],[Office],[Department],[Company],[ProfilePath],[HomePath],[HomeDrive],[Record_Source],[INSERT_TIME],[MailTO],[Auto_Expiration_Enable],[Auto_Expiration_Int],[Auto_Expiration_Peroid],[IP],[Justification],[141],[ADDN],[Mail],[Live_Object_Source] FROM [AMSv1].[dbo].[AMS_Processing_INPROGRESS_ADWrite];", Processing_SQLConnection)
                    Try
                        Processing_DataResults = New DataTable
                        Processing_LoadData.Fill(Processing_DataResults)
                    Catch ex As Exception
                        WinEventLog.WriteEntry("Account Processing: Failed to populate datatable. " & ex.ToString, EventLogEntryType.Warning, 1503)
                        GoTo Processing_Exit
                    End Try
                End Using
            Catch ex As Exception
                WinEventLog.WriteEntry("Account Processing: Failed to bind to SQL", EventLogEntryType.Warning, 1502)
                GoTo Processing_Exit
            End Try

Open in new window


Reason I am using a database instead of direct SQL reads is because I am spinning up multiple threads to process the changes in parallel. and using a datatable you can easily divide up the load.

executing the same statement in sql, I have no nulls.

Has anyone else had this problem / seen this?
I am not going to lie, it is a LOT of data, 40 columns and between 9,000 to 150,000 rows.
0
Comment
Question by:JesNoFear
  • 2
3 Comments
 
LVL 9

Accepted Solution

by:
Trideep Patel earned 500 total points
Comment Utility
Have you put a break point and checked that Processing_DataResults contains null values after Processing_LoadData.Fill(Processing_DataResults) line?
I am just asking it because it might be possible due to parallel for loop or threading.
1
 
LVL 2

Author Comment

by:JesNoFear
Comment Utility
So, directly after this is when the loop's start. it does the load and then spins up the multi-threads.

So, what i have done since this post was in each thread, it is given a range of rows to process, as it goes through the for next loop, i have it checking all the fields for nulls, if it finds a null that is unexpected, it will drop that job and use a continue for and denote in sql to re-process that entry after the cycle is done.

and with that being said, since that change, neither the safeguard check before it does the work or while the work is being done have null's come up. i added a break point if it were to find a null, as well as logging it to windows even log.

so it is still a mystery, i have been flooding it with sets of 9,000 and 15,000 transactions all day. I am about to do another load test with 150,000 transactions and see if it comes back or not, and/or that the safeguard is working.
0
 
LVL 2

Author Closing Comment

by:JesNoFear
Comment Utility
the issue has disappeared since i added the pre-checking.
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

743 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

10 Experts available now in Live!

Get 1:1 Help Now