Hello Everyone, I am connecting to a MS Access database using the DriverManager class and JDBC-ODBC Bridge driver. I am having trouble with a query using the "LIKE" clause in MS Access. When I run the query in Access, it returns results as it ought to, but when I attempt to use this string of SQL in a prepared statement, it returns no records. Here is my code: Code: if(getRecordCount(rs)==0){ System.out.println("No records restrieved for :\n" + strSQL + "\nReassigning query expression"); strSQL = "SELECT * FROM tblNAmes WHERE " + c + " LIKE '*"+ crit + "*' ORDER BY " + c + ";"; System.out.println("New Statement: " + strSQL); System.out.println("Assigning result set"); ps = conn.prepareStatement(strSQL, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY); rs = ps.executeQuery(); } int count = getRecordCount(rs); System.out.println("Records Retrieved: " + count); Here is the output I receive: All of my other query expression (not using "LIKE") work perfectly fine. Does anyone see any glaring errors in this code? I have only recently become familiarizing myself with these tools, so any assistance would be greatly appreciated. Thank you in advance!
fifteen people have looked at this thread and NO ONE has any idea what might be a solution? Back to the old drawing board.
The most likely problem is your LIKE wildcard. Instead of Code: SELECT * FROM tblNAmes WHERE strFirstName [B]LIKE '*a*'[/B] ORDER BY strFirstName; try Code: SELECT * FROM tblNAmes WHERE strFirstName [B]LIKE '%a%' [/B]ORDER BY strFirstName; . Hope that helps, Ted OpenLink Software Technical Support