T
Terry Olsen
I've got 2 different web pages, both updating the same SQL database. One is
for the Technician and one is for the Manager. The technician's update page
works fine but the Manager's update page doesn't. They are both the
same..as far as I can tell...
---------------------
This code works fine, updating the SQL database with the edited data.
Code for Tech Page
Private Sub btnSubmit_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnSubmit.Click
Dim myID As String = Request.QueryString.Get("ID")
Dim myConnection As New
SqlConnection(ConfigurationSettings.AppSettings("ConnectionString"))
Dim strCmd As String = "UPDATE Incidents " & _
"SET SO_Num = '" & txtSONum.Text & "'," & _
"HoursWorked = '" & txtHours.Text & "'," & _
"Comments = '" & txtExistComments.Text & " -- " & txtAddtlComments.Text & "'
" & _
"WHERE ID = '" & myID & "'"
Dim myCommand As New SqlCommand(strCmd, myConnection)
myConnection.Open()
myCommand.ExecuteNonQuery()
myConnection.Close()
SendMailMessage(myID)
Response.Redirect("UpdateComplete.html")
End Sub
---------------------------------------------------
The following code executes with no exceptions. It returns "1" from the
"ExecuteNonQuery" statement. But the SQL Database is not being updated.
When I reload the controls after running this code, all the controls revert
back to what was previously there before I edited. I've sat here staring at
it for hours and can't see anything wrong...
Code for Manager's Page
Private Sub btnSubmit_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnSubmit.Click
Dim myID As String = Request.QueryString.Get("ID")
Dim myConnection As New
SqlConnection(ConfigurationSettings.AppSettings("ConnectionString"))
Dim strCmd As String = "UPDATE Incidents " & _
"SET SO_Num='" & txtSONum.Text & "'," & _
"HoursWorked='" & txtHours.Text & "'," & _
"Comments='" & txtComments.Text & "'," & _
"Center='" & txtCenter.Text & "'," & _
"Date='" & txtDate.Text & "'," & _
"UserName='" & txtUser.Text & "'," & _
"TechEmail='" & txtTech.Text & "' " & _
"WHERE ID='" & myID & "'"
Dim myCommand As New SqlCommand(strCmd, myConnection)
myConnection.Open()
myCommand.ExecuteNonQuery()
myConnection.Close()
Session("Edit") = 1 '1 = Edited
Response.Redirect("IncidentReview.aspx")
End Sub
for the Technician and one is for the Manager. The technician's update page
works fine but the Manager's update page doesn't. They are both the
same..as far as I can tell...
---------------------
This code works fine, updating the SQL database with the edited data.
Code for Tech Page
Private Sub btnSubmit_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnSubmit.Click
Dim myID As String = Request.QueryString.Get("ID")
Dim myConnection As New
SqlConnection(ConfigurationSettings.AppSettings("ConnectionString"))
Dim strCmd As String = "UPDATE Incidents " & _
"SET SO_Num = '" & txtSONum.Text & "'," & _
"HoursWorked = '" & txtHours.Text & "'," & _
"Comments = '" & txtExistComments.Text & " -- " & txtAddtlComments.Text & "'
" & _
"WHERE ID = '" & myID & "'"
Dim myCommand As New SqlCommand(strCmd, myConnection)
myConnection.Open()
myCommand.ExecuteNonQuery()
myConnection.Close()
SendMailMessage(myID)
Response.Redirect("UpdateComplete.html")
End Sub
---------------------------------------------------
The following code executes with no exceptions. It returns "1" from the
"ExecuteNonQuery" statement. But the SQL Database is not being updated.
When I reload the controls after running this code, all the controls revert
back to what was previously there before I edited. I've sat here staring at
it for hours and can't see anything wrong...
Code for Manager's Page
Private Sub btnSubmit_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnSubmit.Click
Dim myID As String = Request.QueryString.Get("ID")
Dim myConnection As New
SqlConnection(ConfigurationSettings.AppSettings("ConnectionString"))
Dim strCmd As String = "UPDATE Incidents " & _
"SET SO_Num='" & txtSONum.Text & "'," & _
"HoursWorked='" & txtHours.Text & "'," & _
"Comments='" & txtComments.Text & "'," & _
"Center='" & txtCenter.Text & "'," & _
"Date='" & txtDate.Text & "'," & _
"UserName='" & txtUser.Text & "'," & _
"TechEmail='" & txtTech.Text & "' " & _
"WHERE ID='" & myID & "'"
Dim myCommand As New SqlCommand(strCmd, myConnection)
myConnection.Open()
myCommand.ExecuteNonQuery()
myConnection.Close()
Session("Edit") = 1 '1 = Edited
Response.Redirect("IncidentReview.aspx")
End Sub