hi...need help updating records in a database....already did the registration and login pages and works fine...when the user logins he is able update his details on the update page...when the update page loads, his details will be displayed in the respective textboxes for him to edit...
managed to read the user's details like this..in the page_load procedure.....
already initialised Session("ID") in login page...
Session("ID") = Me.txtUsername.Text.Trim
but not able to update his details...did this to update.
weird thing is if i erased all codes under the page_load to read, i can update successfully....can someone help??..thanks...
managed to read the user's details like this..in the page_load procedure.....
VB.NET:
Dim dbcon As New OleDbConnection
Dim strConn As String
strConn = "Provider=Microsoft.Jet.OLEDB.4.0;"
strConn += "Data Source=" & Server.MapPath("dvd_rental.mdb") & ";User ID=Admin; Password=;"
dbcon.ConnectionString = strConn
dbcon.Open()
Dim command As New OleDbCommand("SELECT Username, Email, Name, Country FROM Login WHERE Username = '" + Session("ID") + "'", dbcon)
Dim reader As Data.OleDb.OleDbDataReader = command.ExecuteReader
reader.Read()
Textbox1.Text = reader("Username")
txtEditeMail.Text = reader("Email")
txtEditName.Text = reader("Name")
txtEditCountry.Text = reader("Country")
reader.Close()
dbcon.Close()
Session("ID") = Me.txtUsername.Text.Trim
but not able to update his details...did this to update.
VB.NET:
Dim dbcon As New OleDbConnection
Dim strConn As String
Dim adapter As New OleDbDataAdapter("SELECT ID,Username,Pass, Email, Country FROM Login ", dbcon)
strConn = "Provider=Microsoft.Jet.OLEDB.4.0;"
strConn += "Data Source=" & Server.MapPath("dvd_rental.mdb") & ";User ID=Admin; Password=;"
dbcon.ConnectionString = strConn
Dim cmd As New OleDbCommand("UPDATE Login SET Username= @Username ,Pass = @Pass, Email = @Email ,Country= @Country WHERE [Username]=@Username1", dbcon)
cmd.Parameters.AddWithValue("@Username", Textbox1.Text)
cmd.Parameters.AddWithValue("@Pass", txteditPassword1.Text)
cmd.Parameters.AddWithValue("@Email", txtEditeMail.Text)
cmd.Parameters.AddWithValue("@Country", txtEditCountry.Text)
cmd.Parameters.AddWithValue("@Username1", Session("ID"))
adapter.UpdateCommand = cmd
dbcon.Open()
cmd.ExecuteNonQuery()
dbcon.Close()
adapter.MissingSchemaAction = MissingSchemaAction.AddWithKey
Dim table As New DataTable
adapter.Fill(table)
adapter.Update(table)
pnlsigninsuccessful.Visible = True
pnlEdit.Visible = False
weird thing is if i erased all codes under the page_load to read, i can update successfully....can someone help??..thanks...