I have a aspx page and created a button to take the values from the textboxes and update the sql tables respectively. However, the updates aren't happening.
Here's my code:
Try
'Define database connection
myconnection_1 = New SqlClient.SqlConnection("s
erver=xxx;
user=xxxx;
password=rxxx;database = " & DropDownList1.SelectedItem
.Value)
myconnection_1.Open()
Dim command As String
Dim command2 As String
Dim dbcommand As SqlCommand = New SqlCommand(command, myconnection_1)
'set up an SQL update
command = "update [user] set FirstName = '" & _
TextBox1.Text & "', " & " LastName = '" & TextBox2.Text _
& "', " & " Group = '" & DropDownList2.SelectedItem
.Text _
& "', " & " ProfessionalType = '" & DropDownList3.SelectedItem
.Text _
& " Password = '" & TextBox4.Text _
& "' where UserName = '" & TextBox6.Text & "'"
Dim dbcommand2 As SqlCommand = New SqlCommand(command2, myconnection_1)
command2 = "update [Professional] set FirstName = '" & _
TextBox1.Text & "', " & " LastName = '" & TextBox2.Text _
& "', " & " PatientGroupID = '" & DropDownList2.SelectedItem
.Text _
& "', " & " ProfessionalType = '" & DropDownList3.SelectedItem
.Text _
& "' where UserId = (select userid from [user] where username = '" & TextBox6.Text & "'"
'Execute stored procedures
dbcommand.ExecuteNonQuery(
)
dbcommand2.ExecuteNonQuery
()
Catch exceptionObject As Exception
Label12.Text = ""
Finally
myconnection_1.Close()
End Try
Label12.Text = "Record has been Updated !"
End Sub
Start Free Trial