This is my code. I want to update the data behind the Save button, but when I hit it, it refreshes the page and does not show updated data. It also does not update in the Database.
also is there a way that this does not refresh, something like an update panel?
Code:
Dim conn As SqlConnection
Dim cmd As SqlCommand
Dim fname As String
Dim lname As String
Dim DOB As String
Dim PatientNumber As String
Dim address1 As String
Dim address2 As String
Dim town As String
Dim county As String
Dim postcode As String
Dim ContactNumber As String
Dim Email As String
PatientNumber = CInt(txtPatientNo.Text)
fname = txtFName.Text
lname = txtLName.Text
DOB = txtDOB.Text
address1 = txtAddress1.Text
address2 = txtAddress2.Text
town = txtTown.Text
county = txtCounty.Text
postcode = txtPostcode.Text
ContactNumber = txtContact.Text
Email = txtEmail.Text
Dim cmdstring As String = "UPDATE PatientDetails SET FirstName = @FNAME, Surname = @LNAME, DateOfBirth = @DOB, Address = @ADDRESS1, Address2 = @ADDRESS2, Town = @TOWN, County = @COUNTY, Postcode = @POSTCODE, ContactNumber = @CONTACTNUMBER, EmailAddress = @EMAIL WHERE PatientNumber = @PatientNumber"
conn = New SqlConnection("Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=E:\myAppointments\App_Data\Database.mdf;Integrated Security=True")
cmd = New SqlCommand(cmdstring, conn)
cmd.Parameters.AddWithValue("@PATIENTNUMBER", PatientNumber)
cmd.Parameters.AddWithValue("@FNAME", fname)
cmd.Parameters.AddWithValue("@LNAME", lname)
cmd.Parameters.AddWithValue("@DOB", DOB)
cmd.Parameters.AddWithValue("@ADDRESS1", address1)
cmd.Parameters.AddWithValue("@ADDRESS2", address2)
cmd.Parameters.AddWithValue("@TOWN", town)
cmd.Parameters.AddWithValue("@COUNTY", county)
cmd.Parameters.AddWithValue("@POSTCODE", postcode)
cmd.Parameters.AddWithValue("@CONTACTNUMBER", ContactNumber)
cmd.Parameters.AddWithValue("@EMAIL", Email)
conn.Open()
cmd.ExecuteNonQuery()
conn.Close()