Why is it that when i run this codes i get no errors (Label states that account is updated) BUT in reality at the database side no changes occurs at the data. ID is displayed in a label everytime the page loads. Thanks in advance.
VB.NET:
Dim DBConn As New Data.SqlClient.SqlConnection("DATA SOURCE = xxx; INITIAL CATALOG = xxx;Integrated Security=True")
Dim DBCmd As New Data.SqlClient.SqlCommand
Dim DBAdap As New Data.SqlClient.SqlDataAdapter
Dim DS As New Data.DataSet
DBConn.Open()
Try
DBCmd = New Data.SqlClient.SqlCommand("UPDATE LOG_IN SET EMAIL = @EMAIL, PASSWORD = @PASSWORD, FIRSTNAME = @FIRSTNAME, LASTNAME = @LASTNAME, GENDER = @GENDER, BIRTHDATE = @BIRTHDATE, BIRTHPLACE = @BIRTHPLACE WHERE ID = @ID", DBConn)
DBCmd.Parameters.Add("@ID", Data.SqlDbType.Int).Value = Label1.Text
DBCmd.Parameters.Add("@EMAIL", Data.SqlDbType.VarChar).Value = TextBox1.Text
DBCmd.Parameters.Add("@PASSWORD", Data.SqlDbType.VarChar).Value = TextBox2.Text
DBCmd.Parameters.Add("@LASTNAME", Data.SqlDbType.VarChar).Value = TextBox3.Text
DBCmd.Parameters.Add("@FIRSTNAME", Data.SqlDbType.VarChar).Value = TextBox4.Text
DBCmd.Parameters.Add("@GENDER", Data.SqlDbType.VarChar).Value = TextBox7.Text
DBCmd.Parameters.Add("@BIRTHDATE", Data.SqlDbType.VarChar).Value = TextBox6.Text
DBCmd.Parameters.Add("@BIRTHPLACE", Data.SqlDbType.VarChar).Value = TextBox5.Text
DBCmd.ExecuteNonQuery()
Label7.Text = ("Your account is updated.")
DBAdap = New Data.SqlClient.SqlDataAdapter("SELECT * FROM LOG_IN", DBConn)
DBAdap.Fill(DS)
DataBind()
Catch ex As Exception
Label7.Text = ("Your account was not updated.")
End Try
DBCmd.Dispose()
DBAdap.Dispose()
DBConn.Close()
DBConn = Nothing