Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

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

Posted on 2011-04-21
2
Medium Priority
?
185 Views
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
0
Comment
Question by:dyarosh
2 Comments
 
LVL 17

Accepted Solution

by:
Carlos Villegas earned 2000 total points
ID: 35445214
Hello, change:
queryStr = "SSN=" & ec.SSN

Open in new window

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

Open in new window

0
 

Author Closing Comment

by:dyarosh
ID: 35445247
Thank you.  That fixed it.
0

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

Question has a verified solution.

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

You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.

864 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