Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to Insert data into MS Access?

 
ltanuwij
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have created a java swing code that is connected to the MS access 2000, I would like to know how to use the "Insert into" I can use the "SELECT"
What i did: INSERT INTO table_name (field_name) VALUES (the value)
and i always get this error message;
java.sql.SQL.EXCEPTION:[Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 1

In my table there is only one field which is called "Name"
Thank you
 
ltanuwij
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Don't worry i solved it
 
Frank Carver
Sheriff
Posts: 6920
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Itanuwij",
The Java Ranch has thousands of visitors every week, many with surprisingly similar names. To avoid confusion we have a naming convention, described at http://www.javaranch.com/name.jsp .
We require names to have at least two words, separated by a space, and strongly recommend that you use your full real name. Please log in again with a new name which meets the requirements.
Thanks.
 
Amit Barot
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes u can insert into the MS ACCESSS 2000
pass the string into the
statement.executeQuery("insert into <table Name>(<field1,field2) values('String','String',Integer)>
look the followwing thing is a new thing which i found out
if u hav some value assinged to a variable like
String name = "amit";
and if u want to insert that variable then the syntax in the VALUES will be values('"+name+'",'"+name2+"')otherwise u will get an SQLException java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 1.
ok then this might solve your query
bye.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic