• Post Reply Bookmark Topic Watch Topic
  • New Topic

problem with updating records in ms access  RSS feed

 
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Im having this very weird problem with updating records in MS access..
I do this:

stat3.executeUpdate("UPDATE table1 SET weight='" + t.getWeight().trim() + "' WHERE name='" + k + "');

i dont get an exception but the record doesnt get updated..

Then i try this:

r2 = stat3.executeQuery("SELECT * FROM table1 WHERE name='" + t.getName().trim() + "'");
r2.next();

r2.updateString("weight",t.getWeight().trim());
r2.updateRow();


It doesnt work..

if i setup stat3 as :
stat3 = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);

I get an invalid cursor state error.

If i set it up as just :
stat3 = con.createStatement();

I dont get an error, but the records still doesnt get updated! Help!

What could be causing this? (the db i'm using is ms access 97)
 
Ranch Hand
Posts: 961
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When you execute the Statement.executeUpdate(String sql) it should return a number with the count of the affected rows.

When you invoke your...



...does it return a value bigger the 0?

Because if it doesn't, that means that there is nothing wrong with your code, it is just that your are not actually updating anything.
 
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is a common problem, search this forum for 'access insert'
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!