Error when doing a Query Search on my Dataset in VB.Net

I have a VB.Net Windows Application that uses a MS Access Database.  One of the functions of the application reads from an Excel file that contains employee info of which one of the fields is the SSN.  It uses the SSN to see if the employee exists in the MS Access database using the following code (ec.SSN is declared as a String):

                        queryStr = "SSN=" & ec.SSN  
                        EmployeeRowArray = Me.HwDataSet.Employee.Select(queryStr)
                        If EmployeeRowArray.Count > 0 Then

Everything works fine until I get to a row in the Excel file whose SSN is 451xxxx10.  I get the error shown in the attached file when I execute EmployeeRowArray = Me.HwDataSet.Employee.Select(queryStr) and I can't figure out why.  Initially I thought it had something to do with a limit and the SSN was greater than that limit but the file has other SSNs that are greater than 451xxxx10 and it works fine.  If I remove the row that has 451xxxx10 as it's SSN, the function works fine.  This leads me to believe that it is a data problem but I can't figure out what is different about this particular row.  Any help would be greatly appreciated. VB Error
dyaroshAsked:
Who is Participating?
 
Carlos VillegasConnect With a Mentor Full Stack .NET DeveloperCommented:
Hello, change:
queryStr = "SSN=" & ec.SSN

Open in new window

For:
queryStr = "SSN='" & ec.SSN & "'"

Open in new window

0
 
dyaroshAuthor Commented:
Thank you.  That fixed it.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.