Results 1 to 7 of 7

Thread: insert statement problems{Resolved}

  1. #1

    Thread Starter
    Frenzied Member System_Error's Avatar
    Join Date
    Apr 2004
    Posts
    1,111

    Resolved insert statement problems{Resolved}

    I'm having problems updating a database. I use the prepared statement because I want to call some methods to get the values to return. The program compiles and runs fine, but it doesn't update the database.

    Code:
    PreparedStatement stmt = databaseConnection.prepareStatement("INSERT INTO Session (Last_Name, First_Name,User_Name, Password, Gender, Email_Address) VALUES(?,?, ?, ?, ?, ?)");
     
    				stmt.setString(1, "B");
    				stmt.setString(2, "C");
    				stmt.setString(3, "D");
    				stmt.setString(4, "E");
    				stmt.setString(5, "F");
    				stmt.setString(6, "G");
    				stmt.executeUpdate();
    That's how I'm doing it. I made sure everything is the same between the DB and my code, so I don't think that's a problem.
    Last edited by System_Error; Jun 6th, 2005 at 05:57 PM.

  2. #2

    Thread Starter
    Frenzied Member System_Error's Avatar
    Join Date
    Apr 2004
    Posts
    1,111

    Re: insert statement problems

    Oooops. Just forgot to close the connection. Resolved.

  3. #3
    Frenzied Member oceanebelle's Avatar
    Join Date
    Jun 2005
    Location
    my n00k.
    Posts
    1,064

    Re: insert statement problems{Resolved}

    It happens, we look for something sooo complex and tend to forget the loose ends! wot a bummer :'(

  4. #4

    Thread Starter
    Frenzied Member System_Error's Avatar
    Join Date
    Apr 2004
    Posts
    1,111

    Re: insert statement problems{Resolved}

    Well actually I think it's a flaw in access that causes it not to register updates unless the connection is closed, but I should have closed it anyway.

  5. #5
    Dazed Member
    Join Date
    Oct 1999
    Location
    Ridgefield Park, NJ
    Posts
    3,418

    Re: insert statement problems{Resolved}

    System Error did you do a check to see what was being returned from executeUpdate()? Inserts fall under DML so executeUpdate() should return 1.

    executeUpdate should only return 0 if an update statement that affects zero rows is executed or it's a DDL statement that's executed.

  6. #6

    Thread Starter
    Frenzied Member System_Error's Avatar
    Join Date
    Apr 2004
    Posts
    1,111

    Re: insert statement problems{Resolved}

    Quote Originally Posted by Dilenger4
    System Error did you do a check to see what was being returned from executeUpdate()? Inserts fall under DML so executeUpdate() should return 1.

    executeUpdate should only return 0 if an update statement that affects zero rows is executed or it's a DDL statement that's executed.
    Nah, I had no clue about that. I'm guessing that it actually did do the update, but would only show up after the connection was closed.

    Let me test it and see....

  7. #7

    Thread Starter
    Frenzied Member System_Error's Avatar
    Join Date
    Apr 2004
    Posts
    1,111

    Re: insert statement problems{Resolved}

    It did return a 1. So it is a flaw in access that it only shows up after the connection is closed, even though the update has already taken place.

Posting Permissions

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



Click Here to Expand Forum to Full Width