Solved

Null Values in Datatable - VB.Net

Posted on 2016-08-07
3
50 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
ID: 41746673
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
ID: 41748008
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
ID: 41749507
the issue has disappeared since i added the pre-checking.
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
ADO.NET ENTITY DATA MODEL 3 30
Error on Add method 1 37
how to read json value 2 29
SQL Exceptions 3 36
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
A company’s greatest vulnerability is their email. CEO fraud, ransomware and spear phishing attacks are the no1 threat to a company’s security. Cybercrime is responsible for the largest loss of money to companies today with losses projected to r…

914 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

20 Experts available now in Live!

Get 1:1 Help Now