| Author |
fail to update.
|
joo how
Greenhorn
Joined: Apr 18, 2012
Posts: 9
|
|
the result was
java.sql.SQLException: No data found
java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver]Error in row
java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver]Invalid cursor position; no keyset defined
anyone can help ?
[Added code tags - see UseCodeTags for details]
|
 |
William P O'Sullivan
Ranch Hand
Joined: Mar 28, 2012
Posts: 860
|
|
It looks like you haven't established the cursor position.
You can only update something that you have already retrieved or use a Where clause in standard sql/jdbc.
WP
|
 |
joo how
Greenhorn
Joined: Apr 18, 2012
Posts: 9
|
|
|
can you teach me what i need to do ?? i am new in this == was helping my friend to solve this problem.
|
 |
Greg Charles
Bartender
Joined: Oct 01, 2001
Posts: 2536
|
|
Welcome to JavaRanch!
You can see an example here. If you're still having trouble post a small example that shows how you create the query and just update one field.
|
 |
Wendy Gibbons
Bartender
Joined: Oct 21, 2008
Posts: 1098
|
|
You haven't shown us what sort of result set you have, as this only works on certain types (after a quick read of the API)
http://docs.oracle.com/javase/6/docs/api/java/sql/ResultSet.html
|
 |
joo how
Greenhorn
Joined: Apr 18, 2012
Posts: 9
|
|
Greg Charles wrote:Welcome to JavaRanch!
You can see an example here. If you're still having trouble post a small example that shows how you create the query and just update one field.
thanks! Greg.
I type the exactly what the page have, but still give me the same error. the example :
updateButton.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
int id = 520;
String city = "KL";
try{
statement = connection.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);
resultSet = statement.executeQuery("select * from Employee");
resultSet.first();
resultSet.updateInt("EmpID", id);
resultSet.updateString("City", city);
resultSet.updateRow();
JOptionPane.showMessageDialog(null,"Record updated.");
}catch(Exception ex){
System.out.println(ex.toString());
}
}
});
|
 |
joo how
Greenhorn
Joined: Apr 18, 2012
Posts: 9
|
|
do you mean this i missed?
statement = connection.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);
resultSet = statement.executeQuery("select * from Employee");
|
 |
Wendy Gibbons
Bartender
Joined: Oct 21, 2008
Posts: 1098
|
|
joo how wrote:
do you mean this i missed?
statement = connection.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);
resultSet = statement.executeQuery("select * from Employee");
yes in the first post, but not the later post.
|
 |
joo how
Greenhorn
Joined: Apr 18, 2012
Posts: 9
|
|
Wendy Gibbons wrote:
joo how wrote:
do you mean this i missed?
statement = connection.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);
resultSet = statement.executeQuery("select * from Employee");
yes in the first post, but not the later post.
I added resultSet.absolute(1);
but still giving me the error : java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver]Error in row.
|
 |
joo how
Greenhorn
Joined: Apr 18, 2012
Posts: 9
|
|
|
Guys! thanks! i solved it
|
 |
Greg Charles
Bartender
Joined: Oct 01, 2001
Posts: 2536
|
|
|
Good for you! It would be nice if you could explain how you fixed it. Then everyone learns!
|
 |
joo how
Greenhorn
Joined: Apr 18, 2012
Posts: 9
|
|
haha. sure!
one of my friend told me the reason why error in row is because
1. One or more required fields were not filled
2. One of entered values do not conform field type (character values in numeric or date fields)
3. You trying to enter a value into field which is of Autonumber type.
4. You have a relationship between tables that requires you to put into foreign key field one of existing values from another table. If you put value that don't exist in another table you see the same error.
then i found there is one data type in access was wrong. so, after i changed it. it works!
|
 |
Greg Charles
Bartender
Joined: Oct 01, 2001
Posts: 2536
|
|
|
Great, thanks! I hope you'll stick around and ask and/or answer some more questions here!
|
 |
 |
|
|
subject: fail to update.
|
|
|