How to use INSERT INTO Statement in MS Access Database

  • Follow


I have a table (Wares) in MS Access database with defined field - type
Date/Time (date). I am trying to put a value in this field
programmaticaly using Java language (MS Access Driver) with following
SQL string (example):

INSERT INTO Wares (date) VALUES ('3.6.2003')

but I receive an error "Syntax error in INSERT INTO statament..."

I've tried to use ( " ) characted instead ( ' ) but error still
occurs. Where is the syntax error?
I've tried to use also PreparedStatement object (prepStat) with
following code:

String sql = "INSERT INTO Wares (date) VALUES (?)";
prepStat.setDate( 1, new
java.sql.Date( calendar.getTimeInMillis() ) );

where calendar object is predefined with desired values.

but nothing, the error is still the same.
Thanks for any helps.

0
Reply jilt3d.uni (3) 4/7/2007 8:15:00 PM

Try doing like this:
ps=connection.PreparedStatement("Insert into wares values(?,?..)");
ps.setDate(1,date);
ps.setString(2,str1);
.....
ps.executeUpdate();

Or if you want to update only a single field use Update :
ps.connection.preparedStatement("Update wares where date=?");
ps.setDate(1.date);
ps.executeUpdate();


0
Reply ruds 4/11/2007 9:06:30 AM


1 Replies
776 Views

(page loaded in 0.033 seconds)

Similiar Articles:













7/21/2012 9:14:15 PM


Reply: