Re: querying an access table



and finally, the wild card character must be a "%" not an asterisk like
in Access.



Justin wrote:
I have partially figured this out. In the "WHERE" statement, single
quotes must be used instead of double quotes. However, use of the wild
card character (*) does not work. It only returns exact matches.

Justin wrote:
I followed the tutorial here
http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=2691&lngWId=2
to gain connectivity to an MS Access database. I generated a query
within access and the inserted it into my java code.

the query is show below:

SELECT demographics.sSN, demographics.lastName, demographics.firstName
FROM demographics
WHERE (((demographics.lastName) Like "Lo*"));

This query works perfectly when run in access. However, when I run it
in Java, it causes the following exception:

java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Too
few parameters. Expected 1.
at
sun.jdbc.odbc.JdbcOdbc.createSQLException(JdbcOdbc.java:6958)
at sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:7115)
at sun.jdbc.odbc.JdbcOdbc.SQLExecDirect(JdbcOdbc.java:3111)
at
sun.jdbc.odbc.JdbcOdbcStatement.execute(JdbcOdbcStatement.java:338)
at
sun.jdbc.odbc.JdbcOdbcStatement.executeQuery(JdbcOdbcStatement.java:253)

When I remove the criteria from the query (ie WHERE
(((demographics.lastName) Like "Lo*"));) I can get the data to return,
but naturally, it returns all entries in the database.

As always, any help is greatly appreciated

.



Relevant Pages

  • Re: how to link to a csv file with a date field in it?
    ... Regarding the scheduler it's in XP and above - if you aren't familiar with using the Windows Task Scheduler, here is a link to a fairly clean, simple, short tutorial. ... I think you have the right idea - link to the csv, maybe run an append query to process the contents into your main table, in that query you can fix things such as the date. ... s is the complete row of data as a string, flag is a boolean that is initialized to be False. ... The full code I snipped this from contains so much checking for quotes and # hashes and internal commas and internal single quotes replacing certain chars, that it's difficult for me to follow and I wrote it. ...
    (microsoft.public.access.externaldata)
  • Re: how to link to a csv file with a date field in it?
    ... I think you have the right idea - link to the csv, maybe run an append query to process the contents into your main table, in that query you can fix things such as the date. ... s is the complete row of data as a string, flag is a boolean that is initialized to be False. ... We can create a recordset object and set it to a specific table - we add the new row one field at a time, testing each field for type using a select case, add the # for dates or ' for text or nothing for numeric field types to the fldArrrayelement contents and the set rs.fields= the resulting expression. ... The full code I snipped this from contains so much checking for quotes and # hashes and internal commas and internal single quotes replacing certain chars, that it's difficult for me to follow and I wrote it. ...
    (microsoft.public.access.externaldata)
  • Aging Function
    ... I took your advice and the query worked! ... total debits for those accounts, ... >problem with using the accounts as criteria. ... >it was a result of the missing single quotes. ...
    (microsoft.public.access.modulesdaovba)
  • Re: Question on displaying repeating data
    ... Next, I have to choose the link from the main form, to the subform. ... >> of historical quotes. ... The query logic is relatively simple. ... >> My problem is that I don't know how to display this. ...
    (microsoft.public.access.forms)
  • pop-up form to filter report
    ... when writing sql code use double quotes to ... denote the sql query text and single quotes for string ... John is right about the need to lose the ...
    (microsoft.public.access.reports)