Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

extracting from text field

 
Renuka Kilambi
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I am using an access database. when I am trying to extract data type in a text field and trying to insert that data in to the file an error saying that wrong syntax in the sql statement INSERT... is being displayed. when I am directly giving the string instead of inserting from textfield,everything is turning out tobe fine.
Any ideas?
Thanks
Renuka
 
Frank Carver
Sheriff
Posts: 6920
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you show us the SQL for your "INSERT" statement. SQL syntax errors can often be found just by looking at the SQL.
 
Renuka Kilambi
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Frank,
This is the syntax of INSERT STATEMENT.Any error in this?
String stt = " INSERT INTO"+tablename+" VALUES(" + aa +")";
st.executeUpdate(stt);
Thanks
Renuka
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try these adding ';'
Depending upon the driver ';' to your sql statement... it maybe required.

------------------
We learn more from our mistake's than from our success's.
Monty6
[This message has been edited by monty6 (edited September 27, 2000).]
 
Renuka Kilambi
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Monty6,
I could not get what you are saying. I did add a ; at the end of the SQL querry. But again the result was same. Is that what you adviced me to do?Could you please explain once again?
Thanks
Renuka
 
Thomas Paul
mister krabs
Ranch Hand
Posts: 13974
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What exactly is "aa"? What kind of object is it?
 
Bob Reardon
Ranch Hand
Posts: 161
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try using single quotes ('aa') instead of double quotes.
String stt = "INSERT INTO " + tablename + " VALUES('" + aa + "')";
This works when I insert text or string values into MS SQL Server 7.
-Bob
[This message has been edited by Bob Reardon (edited September 27, 2000).]
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Add ';' to the end of the sql string.
ver 1 String sql1 = "select * from emp;";
(or)
ver 2 String sql2 = "select * from emp";
Depending on which jdbc driver you are using.
The ';' maybe optionial (or) it maybe required.
Also, i come accross some driver that are case sensitive.
Hope this clears things up....
------------------
We learn more from our mistake's than from our success's.
Monty6
[This message has been edited by monty6 (edited September 28, 2000).]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic