473,473 Members | 1,491 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

problem in the update

37 New Member
Hi to all... in the following code... i hav problem in the update.. it is updating upto qty and it is not updating value.. it shows error like syntax error in the update statement.... help me to solve this problem

Regards
Pradeep


Expand|Select|Wrap|Line Numbers
  1.  try
  2.   {
  3.    String query = "insert into Gis values('"+s1+"','"+s2+"','"+s3+"','"+s4+"','"+s5+"','"+s6+"','"+s7+"','"+s8+"','"+s10+"')";
  4.    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
  5.    con=DriverManager.getConnection("jdbc:odbc:prism");
  6.    stmt=con.createStatement();
  7.    stmt1=con.createStatement();
  8.  
  9.    stmt1.executeUpdate(query);
  10.  
  11.    rs=stmt.executeQuery("select * from Stores");
  12.  
  13.   while(rs.next())
  14.   {
  15.  if((rs.getString("ITEMNAME").equals(s5))||(rs.getString("DEPT").equals(s2)))
  16.  {
  17.  
  18.  int n=(rs.getInt(5));
  19.  int n1=n-s6;
  20.  int n2=(rs.getInt(6));
  21. int n3=n2-s10;
  22.  
  23.  String str="UPDATE Stores SET QTY='"+n1+"',VALUE='"+n3+"' WHERE DEPT='"+s2+"'AND ITEMNAME='"+s5+"'"; 
  24.  stmt2=con.createStatement();
  25.  stmt2.executeUpdate(str);
  26. JOptionPane.showMessageDialog(this,new String("GOODS ISSUED"));
  27.  
  28.  }
  29.  }  
  30.  }
  31.  catch(ClassNotFoundException e)
  32. {
  33.   System.out.println(e);
  34. }
  35. catch(SQLException e)
  36. {
  37.   System.out.println(e);
  38.  }
Oct 17 '07 #1
6 1556
JosAH
11,448 Recognized Expert MVP
Line 23 looks suspicious to me, especially because n1 and n3 are ints which you
don't have to quote like '42' etc. in SQL.

kind regards,

Jos
Oct 17 '07 #2
pradeep84
37 New Member
i think thats not a problem... when i gave a single column to update.. it gets updated.. when i tried to update two columns... its showed an error message..

Thanks

Regards
Pradeep
Oct 17 '07 #3
JosAH
11,448 Recognized Expert MVP
i think thats not a problem... when i gave a single column to update.. it gets updated.. when i tried to update two columns... its showed an error message..

Thanks

Regards
Pradeep
And what is the exact text of the error message?

kind regards,

Jos
Oct 17 '07 #4
pradeep84
37 New Member
This was the error message......

java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Syntax error in UPDATE statement.


Regards
Pradeep
Oct 17 '07 #5
JosAH
11,448 Recognized Expert MVP
This was the error message......

java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Syntax error in UPDATE statement.


Regards
Pradeep
That one should be easy; print out that 'str' String containing your SQL query and
check what is wrong with it. I still suspect those quotes around those numbers.
Also check out the SQL dialect for Microsft Access and see what the syntax
for the update statement is supposed to be.

kind regards,

Jos
Oct 17 '07 #6
pradeep84
37 New Member
Thank you,.. i ll check it out....


kind regards,
Pradeep
Oct 17 '07 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Ray | last post by:
I have a list of about 20,000 rows that I am updating. I loop through each row in my program and basically do the following (1) select * from TABLE where SID= for update /*lock the row*/ (2)...
7
by: Zachary Hilbun | last post by:
The below is some test code to help me learn how to update a dataset. It is supposed to read the value of UserCounter and write it back. The UserCounter is being read correctly as 0, is 1 when...
5
by: junglist | last post by:
Hi guys, I've been trying to implement an editable datagrid and i have been succesful up to the point where i can update my datagrid row by row. However what used to happen was that once i updated...
2
by: Tom Larard | last post by:
Hi, We have an app which uses the latest version of perl DBI and DBD::Pg to execute a query, using placeholders. It fails to cast the float I send into a number and generates the following...
2
by: Mike Collins | last post by:
I cannot get the correct drop down list value from a drop down I have on my web form. I get the initial value that was loaded in the list. It was asked by someone else what the autopostback was...
3
by: Juan Antonio Villa | last post by:
Hello, I'm having a problem replicating a simple database using the binary log replication, here is the problem: When the master sends an update to the slave, an example update reads as follows:...
7
by: Jon Maz | last post by:
Hi, I have a MySql problem I hope someone can help me with. I'm trying to run an update on a linking table, the update is running into a Primary Key constraint violation, and in my workaround...
2
by: mob1012 via DBMonster.com | last post by:
Hi All, I wrote last week about a trigger problem I was having. I want a trigger to produce a unique id to be used as a primary key for my table. I used the advice I received, but the trigger is...
15
by: Scotty | last post by:
I like to have a good insert, update and delete code The code below sometimes workl ok sometimes doesnt work, what i am doing wrong?? Sub SaveAny() Dim command_builder As New...
11
by: SAL | last post by:
Hello, I have a Gridview control (.net 2.0) that I'm having trouble getting the Update button to fire any kind of event or preforming the update. The datatable is based on a join so I don't know...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.