|
-
Jun 6th, 2005, 05:22 PM
#1
Thread Starter
Frenzied Member
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.
-
Jun 6th, 2005, 05:56 PM
#2
Thread Starter
Frenzied Member
Re: insert statement problems
Oooops. Just forgot to close the connection. Resolved.
-
Jun 7th, 2005, 01:39 AM
#3
Re: insert statement problems{Resolved}
It happens, we look for something sooo complex and tend to forget the loose ends! wot a bummer :'(
-
Jun 8th, 2005, 08:34 AM
#4
Thread Starter
Frenzied Member
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.
-
Jun 8th, 2005, 05:39 PM
#5
Dazed Member
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.
-
Jun 8th, 2005, 08:12 PM
#6
Thread Starter
Frenzied Member
Re: insert statement problems{Resolved}
 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....
-
Jun 8th, 2005, 08:17 PM
#7
Thread Starter
Frenzied Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|