This week's giveaway is in the Spring forum.
We're giving away four copies of REST with Spring (video course) and have Eugen Paraschiv on-line!
See this thread for details.
The moose likes JDBC and Relational Databases and the fly likes autoNumber problem with MS access Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "autoNumber problem with MS access" Watch "autoNumber problem with MS access" New topic

autoNumber problem with MS access

taha khalid

Joined: May 22, 2012
Posts: 5

I'm trying to make a search bar in java that searchs through a MS access DB .. specifically in a field that holds autoNumber format variables .. the problem that I have is the variable that gets the search value from a text field (I converted it to integer to be comparable with the autoNumber ) this approach is not working but when I change the variable that gets the text field from integer to string and change the autoNumber to a string value the code works.

Please help
Wei Dai
Ranch Hand

Joined: Jun 22, 2005
Posts: 86
Wendy Gibbons

Joined: Oct 21, 2008
Posts: 1107

Hi you two I have added code tags to both of your posts, see how much nicer it looks.
For starters you can tell which quotes you have.
Baseet Ahmed
Ranch Hand

Joined: Dec 18, 2006
Posts: 225

AsSalaamualaikum Taha khalid:

String sql = "select ID from student_info where ID ='"+a+"'";

What is the data type of your ID column in MS Access DB?

You are using variable a with single quote(' '). So check if it Integer(Number) or string(Text).

I agree. Here's the link:
subject: autoNumber problem with MS access
It's not a secret anymore!