Results 1 to 3 of 3
  1. #1
    Join Date
    Aug 2008

    Unanswered: Still lost with update query

    So i have a JTable displaying my search results. It has three columns, Nationality, First_Name and Last_Name, and 9 rows of data. Now i have decided for the sake of simplicaty till i get used to this, when the user clicks the update button, the new table model will just replcae everything in the database, so no need for any model listeners or hash codes, lol, etc.
    So this is how it should be:

    JTable displaying
    9 rows of data

    User edits this JTable

    New table model sent
    to database and replaces
    table with the old data

    So i have started the statement
    String sql = "UPDATE tblCompetitor " +
    "SET Nationality = ?, First_Name = ?, Last_Name = ? " +
    "WHERE roundType2 = ? " +
    "AND eveType2 = ?";
    This is mainly related to java which is why the sql statement looks different. And i know i shouldnt be using parameters but java allows you to do this which is why i have the ? What i really need to know is whether i am doing the format of the update correctly. If you had a table in your database, with 3 columns and 9 rows, and you wanted to update it completely with a whole new set of 9 rows, how would you perform this using the update statement?

  2. #2
    Join Date
    Nov 2007
    Adelaide, South Australia
    I wouldn't use an Update. I'd use a Delete query and then an Append query.

    It's also hard to debug this since it's in Java...

    It looks to me like you are using too many parameters.


    It has three columns, Nationality, First_Name and Last_Name
    "WHERE roundType2 = ? " +
    "AND eveType2 = ?";
    You are either lying with the first statement or you have some really crazy errors in your SQL!!

    Finally, I must say, that it is very unclear what you are actually trying to do. Why re-write 9 rows of data when the user clicks a button? Seems to be zero point to that.
    Owner and Manager of
    CypherBYTE, Microsoft Access Development Specialists.
    Microsoft Access MCP.
    And all around nice guy!

    "Heck it's something understood by accountants ... so it can't be 'that' difficult..." -- Healdem
    "...teach a man to code and he'll be frustrated for life! " -- georgev

  3. #3
    Join Date
    Nov 2004
    out on a limb
    Provided Answers: 59
    I'd suggest you ask this question in the Java forum..... As far as I can see its a problem with Java and its way of talking to JET, rather than an Access problem

    would you like it moving there?

    I suspect the problem is going to lie in the quoting of string values
    ie update mytable set surname = "astringvalue"
    I'd rather be riding on the Tiger 800 or the Norton

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts