• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

SQL Queries: Some errors

 
Ranch Hand
Posts: 209
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear Readers,
I am having problems regarding the execution of SQL Queries. My Table in MS Access is as follows:
stodkID - Number - Integer (Field Size)
Stock Symbol - Text - 50
Shares - Number - Long Integer
Price - Number - Long Integer
Buy Date - Date/Time - Input Mask (99/99/0000;0;_)

I have defined queries for Adding, Updating, Finding and Deleting Records.
My Finding query works perfectly but somehow I am facing problems with the others.

My Add query is as follows:
"INSERT INTO Stocks (stockID, 'Stock Symbol', Shares, Price, 'Buy Date') " +
"VALUES (?,?,?,?,?)";

Error while executing:
[Microsoft][ODBC Microsoft Access Driver]Optional feature not implemented


My Update query is as follows:
"UPDATE Stocks " +
"SET stockID = "+ st.getID() + ", " +
"'Stock Symbol' = '" + st.getSymbol()+ "', " +
"Shares = " + st.getShares() + ", " +
"Price = " + st.getPrice() + ", " +
"'Buy Date' = '" + st.getBuyDate() + "' " +
"WHERE stockID = " + id;


Error while executing:
UPDATE Stocks SET stockID = 1, 'Stock Symbol' = 'ASAP', Shares = 14, Price = 50,
'Buy Date' = '2005-09-12 00:00:00' WHERE stockID = 1
[Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 3.


My Delete Record is as follows:
"DELETE FROM Stocks " + " WHERE stockID = " + id;

Error while executing:
It informs me that rows were deleted, but when I open the database to check, the record is still there.

Is it possible that there is a conflict in the versions of the database? The file format is MS Access 2000 but I am currently using MS Access 2003.
[ May 30, 2007: Message edited by: Shyam Prasad Murarka ]
 
author & internet detective
Posts: 42056
926
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The update statement has a syntax error
'Buy Date' = '2005-09-12 00:00:00' - You can't set the date to the string 'Buy Date'. You need to remove the quotes to assign it to a column.

The delete statement looks ok. Is autocommit turned off? Are you in a transaction that is rolling back?
 
Shyam Prasad Murarka
Ranch Hand
Posts: 209
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear Readers,
Ok, first of all sorry. I had put in the wrong column names.
I changed it. And now my update statement does not produce any error... BUT it still does not update the record in the database! Same thing is still happening with Delete statement.
And my error for Add statement is still the same.
What is autocommit? I don't know anything about it? And as far as I know I am not doing any rollback. Its a very simple application.
Thank you for your reply.
 
Jeanne Boyarsky
author & internet detective
Posts: 42056
926
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can you post the source code?
 
If you want to look young and thin, hang around old, fat people. Or this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic