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

Posted on 2011-04-21
Last Modified: 2012-05-11
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
Question by:dyarosh
    LVL 17

    Accepted Solution

    Hello, change:
    queryStr = "SSN=" & ec.SSN

    Open in new window

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

    Open in new window


    Author Closing Comment

    Thank you.  That fixed it.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Why You Should Analyze Threat Actor TTPs

    After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

    Improved? Move/Copy Add-in Replacement - How to avoid the annoying, “A formula or sheet you want to move or copy contains the name XXX, which already exists on the destination worksheet.” David Miller (dlmille)  It was one of those days… I wa…
    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…
    The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
    This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.

    761 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

    14 Experts available now in Live!

    Get 1:1 Help Now