dcsimg
MS-Access, Update not updating
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Jonathan_Lepage
Posted On:   Monday, August 5, 2002 01:02 PM

HI, Got myself a problem with MS-ACCESS, I try to update a field in hte table using the following code and nothing updates in the MS-ACCESS GUI Interface (even after a manual refresh). I tried doing a select ater the databaseConnection.commit() and the Result set shows that the fields are updated. I don't know where to look. heres the code : Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); // Define the data source for the driver String sourceURL = "jdbc:odbc:"+this.DSN; // Create a connection through the DriverManager Connection databaseConnection = DriverManager.getConnection(sourceURL); Statement statement = databaseConnection.createStatement()   More>>


HI,
Got myself a problem with MS-ACCESS, I try to update a field in hte table using the following code and nothing updates in the MS-ACCESS GUI Interface (even after a manual refresh). I tried doing a select ater the databaseConnection.commit() and the Result set shows that the fields are updated. I don't know where to look.


heres the code :


Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
// Define the data source for the driver

String sourceURL = "jdbc:odbc:"+this.DSN;
// Create a connection through the DriverManager

Connection databaseConnection = DriverManager.getConnection(sourceURL);

Statement statement = databaseConnection.createStatement();

int pos = index.lastIndexOf(".txt");


String batchno = index.substring(pos-7,pos);

if(lock)

{


ResultSet rs = statement.executeQuery("SELECT tbatch.worker from tbatch where tbatch.batchno="+batchno);

rs.next();

boolean flag = rs.getString(1).trim().equalsIgnoreCase("INDEXED");

if(!flag)

{

statement.execute("UPDATE tbatch SET tbatch.worker = 'INDEXED' where tbatch.batchno="+batchno) ;
}


}

else
{

statement.execute("UPDATE tbatch SET tbatch.worker = '*notused', tbatch.indexed=tbatch.totaldoc, tbatch.notindexed=0 where tbatch.batchno="+batchno);
}

databaseConnection.commit();

statement.close();

databaseConnection.close();
}

   <<Less

Re: MS-Access, Update not updating

Posted By:   Gautam_Marwaha  
Posted On:   Tuesday, August 6, 2002 02:21 AM

try closing the resultset with rs.close() before running the update SQL. calling commit is of no use unless you have used setAutocommit(false).
About | Sitemap | Contact