Following through how to build the Dorknozzle website, but when Im trying to add my Helpdesk request informationin, chapter 9 page 30, to the sql table by hitting submit request button, Im getting the db error message created in the catch area of the code and nothing gets written to the table
I dont know how to debug very well but have added some watch points in that area of code and get told by them that EmployeeID is not defined, is this because it hasnt opened the table yet ?
Where do I start my fault finding ??? (Looking at the downloaded code for that particualr file - helpdesk.vb.aspx has a completely different set of code - prcedures in use etc)
Partial Class Helpdesk
Inherits System.Web.UI.Page
Protected Sub submitButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles submitButton.Click
If Page.IsValid Then
'code uses the data entered by the user
Dim conn As SqlConnection
Dim comm As SqlCommand
Dim connectionstring As String = ConfigurationManager.ConnectionStrings("dorknozzle").ConnectionString
conn = New SqlConnection(connectionstring)
comm = New SqlCommand(
"INSERT INTO HelpDesk (EmployeeID,StationNumber, " &
"CategoryID, SubjectID, Description, StatusID) " &
"VALUES (@EmployeeID, @StationNumber, @CategoryID, " &
"@SubjectID, @Description, @StatusID)", conn)
comm.Parameters.Add("@EmployeeID", System.Data.SqlDbType.Int)
comm.Parameters("@EmployeeID").Value = 5
comm.Parameters.Add("@StationNumber", System.Data.SqlDbType.Int)
comm.Parameters("@stationNumber").Value = stationTextBox.Text
comm.Parameters.Add("@CategoryID", System.Data.SqlDbType.Int)
comm.Parameters("@categoryID").Value =
categoryList.SelectedItem.Value
comm.Parameters.Add("@SubjectID", System.Data.SqlDbType.Int)
comm.Parameters("@SubjectID").Value =
subjectList.SelectedItem.Value
comm.Parameters.Add("@Description",
System.Data.SqlDbType.NVarChar, 50)
comm.Parameters("@Description").Value =
descriptionTextBox.Text
comm.Parameters.Add("@StatusID", System.Data.SqlDbType.Int)
comm.Parameters("@StatusID").Value = 1
Try
conn.Open()
comm.ExecuteNonQuery()
Response.Redirect("Helpdesk.aspx")
Catch ex As Exception
dberrormessage.Text =
"Error Submitting"
Finally
conn.Close()
End Try
End If
End Sub