473,320 Members | 1,580 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Problem in updating the data

Hi .. to all......
i hav created the following codes in order to update the data... i don't know wats the problem.... plz help me to resolve my problem.........

Regards
Pradeep

Expand|Select|Wrap|Line Numbers
  1.  if(ae.getSource()==mod)
  2. {
  3.  
  4. try 
  5. {
  6.       Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
  7.       con=DriverManager.getConnection("jdbc:odbc:prism");
  8.       stmt1=con.createStatement();
  9.       rs=stmt1.executeQuery("select * from Customerdetails");
  10.  
  11.       while(rs.next())
  12.      {
  13.         String query = "Update Customerdetails SET CompanyName="+s2+",Address="+s3+",PhoneNumber="+s4+",Contactperson="+s5+",EmailAddress="+s6+",FaxNumber="+s7+" where CustomerID='"+s1+"'";         
  14.         Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
  15.         con=DriverManager.getConnection("jdbc:odbc:prism");
  16.         stmt2=con.createStatement();
  17.         stmt2.executeUpdate(query);
  18.   }    
  19. }
  20.  catch(ClassNotFoundException e)
  21. {
  22.   System.out.println(e);
  23. }    
  24. catch(SQLException e)
  25. {
  26.   System.out.println(e);
  27. }
  28.  }
Oct 8 '07 #1
4 1227
dmjpro
2,476 2GB
Hi .. to all......
i hav created the following codes in order to update the data... i don't know wats the problem.... plz help me to resolve my problem.........

Regards
Pradeep

Expand|Select|Wrap|Line Numbers
  1.  if(ae.getSource()==mod)
  2. {
  3.  
  4. try 
  5. {
  6.       Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
  7.       con=DriverManager.getConnection("jdbc:odbc:prism");
  8.       stmt1=con.createStatement();
  9.       rs=stmt1.executeQuery("select * from Customerdetails");
  10.  
  11.       while(rs.next())
  12.      {
  13.         String query = "Update Customerdetails SET CompanyName="+s2+",Address="+s3+",PhoneNumber="+s4+",Contactperson="+s5+",EmailAddress="+s6+",FaxNumber="+s7+" where CustomerID='"+s1+"'";         
  14.         Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
  15.         con=DriverManager.getConnection("jdbc:odbc:prism");
  16.         stmt2=con.createStatement();
  17.         stmt2.executeUpdate(query);
  18.   }    
  19. }
  20.  catch(ClassNotFoundException e)
  21. {
  22.   System.out.println(e);
  23. }    
  24. catch(SQLException e)
  25. {
  26.   System.out.println(e);
  27. }
  28.  }
Did you commit after Updation?

Expand|Select|Wrap|Line Numbers
  1. Connection con = null;
  2. .
  3. .
  4. .
  5. con.commit();
  6.  
Have a look at this.

Debasis Jana
Oct 8 '07 #2
Now i added
Expand|Select|Wrap|Line Numbers
  1. con.commit();
but still i didn't get the output...

regards
pradeep
Oct 8 '07 #3
dmjpro
2,476 2GB
Now i added
Expand|Select|Wrap|Line Numbers
  1. con.commit();
but still i didn't get the output...

regards
pradeep
Where you added that line?
After "stmt2.executeUpdate(query)" :-)
And here you used two connections.
Try to have this style of coding.

Expand|Select|Wrap|Line Numbers
  1. try{
  2. Connection con = null;
  3. Statement stmt = null;
  4. ResultSet rs = null;
  5. Class.forName("your driver class");
  6. con = DriverManager.getConnection(...);
  7. stmt = con.createStatement();
  8. rs=stmt.executeQuery("sql query");
  9. }
  10. catch(SQLException e)
  11. {
  12. }
  13. finally{
  14. con.close();
  15. rs.close();
  16. stmt.close();
  17. }
  18.  
Debasis Jana
Oct 8 '07 #4
r035198x
13,262 8TB
Do not load the driver twice. Why are creating two connections?
Change those things try it and if you get a problem post the exact problem that you get. Don't just say "it does not work".
Oct 8 '07 #5

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

Similar topics

6
by: Hennie de Nooijer | last post by:
Hi, Currently we're a building a metadatadriven datawarehouse in SQL Server 2000. We're investigating the possibility of the updating tables with enormeous number of updates and insert and the...
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)...
1
by: Mark | last post by:
I'm having a problem updating recordsin an Access DB table. I can update other tables in this db with no problem, and I can dreate new record in all of the tables (including this one.)> But I can't...
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...
14
by: Nick Gilbert | last post by:
Hi, I have an asp.net application which runs from a CD-ROM using Cassini. As such, it is single user only. The application connects to an Access database when it is loaded, and keeps the same...
1
by: r2destini | last post by:
Hi Friends, I am new to .Net. So I don't know much. I am facing a problem in updating database through ADO.Net I am creating the dataset and there is no problem in the updation and...
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...
1
by: Christoph Boget | last post by:
I'm experiencing a very odd problem and it's happening only in IE6. IE7, Safari, Opera and Firefox are all working properly. What's happening is that I'm using XHR request responses to update the...
2
by: sirdavethebrave | last post by:
Hi guys - I have written a form, and a stored procedure to update the said form. It really is as simple as that. A user can go into the form, update some fields and hit the update button to...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.