access UPDATE problems

Please support our MS Access and FileMaker Pro advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Reply

Join Date: Nov 2004
Posts: 13
Reputation: dru987 is an unknown quantity at this point 
Solved Threads: 0
dru987 dru987 is offline Offline
Newbie Poster

access UPDATE problems

 
0
  #1
May 13th, 2005
i have a very simple access DB and im tryin to update the records but the update never works. im using asp.net/vb.net and i've include the execute in a try/catch block and it always prints the sql string (the catch). here is my code, perhaps i have an error that ive missed:

SQL = "UPDATE members " & _
         "SET username = '" & txtUsername.Text.Trim() & "', " & _
         "password = '" & txtPassword1.Text.Trim() & "', " & _
         "first_name = '" & txtFirstName.Text.Trim() & "', " & _ 
         "last_name = '" & txtLastName.Text.Trim() & "', " & _
         "email = '" & txtEmail.Text.Trim() & "'" & _
         "WHERE first_name = " & Session("first_name") & _
         "AND last_name = " & Session("last_name") & ""

' Check if connection to DB is already open
If MyConn.State = ConnectionState.Closed Then
    MyConn.Open()
End If

Dim MyCmd As New OleDbCommand(SQL, MyConn)

' Try/Catch...in case DB error
Try
    MyCmd.ExecuteNonQuery()
    MyConn.Close()
    MyConn.Equals("")

    Response.Redirect("default.aspx")

Catch ex As Exception
    profile_error.Text = SQL 
    profile_error.Style("Color") = "red"
End Try

im also adding a user ID soon and will be changing the where to check for the unique ID.
Reply With Quote Quick reply to this message  
Join Date: Jul 2005
Posts: 13
Reputation: Estuardo is an unknown quantity at this point 
Solved Threads: 0
Estuardo Estuardo is offline Offline
Newbie Poster

Re: access UPDATE problems

 
0
  #2
Jul 19th, 2005
G'd evening Dru!
The sintax seems to be fine, but we don't know the values you are sending nor their types. I would sugest to store (just for tests purposes) the sql string in a varible and then write its content in the inmediate window.
Good luck
Estuardo
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 5
Reputation: weilander is an unknown quantity at this point 
Solved Threads: 0
weilander weilander is offline Offline
Newbie Poster

Re: access UPDATE problems

 
0
  #3
Aug 3rd, 2005
What is the error-message?

Maybe you have to put an extra spcace before the last line (" AND last_name = " & Session("last_name") & "")
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the MS Access and FileMaker Pro Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC