0

Here is what I got:

Server Error in '/HRIService' Application.
Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: BC30311: Value of type 'System.Configuration.ConnectionStringSettings' cannot be converted to 'String'.

Source Error:

Line 2: Inherits System.Web.UI.Page
Line 3:
Line 4: Dim conn As New System.Data.SqlClient.SqlConnection(ConfigurationManager.ConnectionStrings("HRIServiceConnectionString1"))
Line 5: Dim cmd As System.Data.SqlClient.SqlCommand
Line 6: Dim reader As System.Data.SqlClient.SqlDataReader = command.ExecuteReader()


Source File: C:\Inetpub\wwwroot\HRIService\ServiceExpress\AddCall.aspx.vb Line: 4

0

Here are the errors ...

Line 6:
Dim reader As System.Data.SqlClient.SqlDataReader = command.ExecuteReader()

Error - 'ExecuteReader' is not a member of 'String'

Line 24 & 25:
Dim FirstName As TextBox = TryCast(FormView1.FindControl("FirstName"), TextBox)
Dim LastName As TextBox = TryCast(FormView1.FindControl("LastName"), TextBox)

Error - already declared in current block

Line 53:
reader = command.ExecuteReader()
Error - 'ExecuteReader' is not a member of 'String'

Line 80:

If Not conn.State = ConnectionState.Open Then conn.Open()
Error - Name ConnectionState is not declared

Line 89:

If bol = True Then DropDownList1.Items.IndexOf(DropDownList1.Items.FindByValue(conID).ToString()))

Error - Value type of 'String' could not be converted to System.Web.UI.WebControls.ListItems

Line 99:
Same as line 80

Line 136 - 140 & 142:
DropDownListEquip.DataSource = reader
Error - Name ' DropDownListEquip' is not declared

Line 172:
Same as line 53

Line 203-205:
cmd.Parameters.AddWithValue("@Problem", Trim(Problem.Text))
cmd.Parameters.AddWithValue("@Priority", DropDownListPriority.SelectedText)
cmd.Parameters.AddWithValue("@Contract", DropDownListBill.SelectedText)

Error - Probelm, ddlpriority, ddlbill not delcared

Line 213:

cmd.Parameters.AddWithValue("@Notes", Trim(Notes.Text))
Error - Notes not declared

Line 226:
Response.Write(ex)
Error - ex not declared

0

Also, Line 4:
Dim conn As New System.Data.SqlClient.SqlConnection(ConfigurationManager.ConnectionStrings("HRIServiceConnectionString1"))

Error - Value of type 'System.Configuration.ConnectionStringSettings' cannot be converted to 'String'.

0
Partial Class AddCall
    Inherits System.Web.UI.Page

    Dim conn As New System.Data.SqlClient.SqlConnection("Data Source=IT-P02\SQLEXPRESS;Initial Catalog=HRIService;Integrated Security=True")
    Dim cmd As System.Data.SqlClient.SqlCommand
    Dim reader As System.Data.SqlClient.SqlDataReader

    Protected Sub Page_Load(ByVal S As Object, ByVal E As System.EventArgs)

    If Not Page.IsPostBack Then

            Dim bol As Boolean = False
            Dim conID As String = Trim(Request.QueryString("conID")).ToString()
            Dim cusID As String = Trim(Request.QueryString("cusID")).ToString()

            If Len(cusID) > 0 And Len(conID) > 0 Then

                Dim FirstName As TextBox = TryCast(FormView1.FindControl("FirstName"), TextBox)
                Dim LastName As TextBox = TryCast(FormView1.FindControl("LastName"), TextBox)
                Dim Company As TextBox = TryCast(FormView1.FindControl("Company"), TextBox)
                Dim Address1 As TextBox = TryCast(FormView1.FindControl("Address1"), TextBox)
                Dim Address2 As TextBox = TryCast(FormView1.FindControl("Address2"), TextBox)
                Dim Phone As TextBox = TryCast(FormView1.FindControl("Phone"), TextBox)
                Dim City As TextBox = TryCast(FormView1.FindControl("City"), TextBox)
                Dim State As TextBox = TryCast(FormView1.FindControl("State"), TextBox)
                Dim Zip As TextBox = TryCast(FormView1.FindControl("Zip"), TextBox)

                Try
                    cmd = New System.Data.SqlClient.SqlCommand("SELECT cusID, FirstName+ ' ' + LastName AS ContactName FROM Contacts WHERE cusID=@cusID ORDER BY LastName, FirstName", conn)
                    cmd.Parameters.AddWithValue("@cusID", cusID)

                    conn.Open()
                    reader = cmd.ExecuteReader()

                    If reader.HasRows Then
                        DropDownList2.DataSource = reader
                        DropDownList2.DataTextField = "ContactName"
                        DropDownList2.DataValueField = "cusID"
                        DropDownList2.DataBind()
                        DropDownList2.Items.Insert(0, ("-- Choose a Contact --"))
                        DropDownList2.SelectedIndex = DropDownList2.Items.IndexOf(DropDownList2.Items.FindByValue(conID))
                    Else
                        DropDownList2.Items.Insert(0, ("-- Error: No Contacts Found --")
                    End If

                    reader.Close()

                    cmd = New System.Data.SqlClient.SqlCommand("SELECT a.Company, a.Address1, a.Address2, b.FirstName, b.LastName, c.City, c.State, c.Zip FROM Customers a JOIN Contacts b ON a.cusID=b.cusID JOIN Zip c ON a.cusID=c.cusID WHERE a.cusID=@cusID and b.ContactID=@conID", conn)
                    cmd.Parameters.AddWithValue("@cusID", cusID)
                    cmd.Parameters.AddWithValue("@ContactID", conID)
                    reader = command.ExecuteReader()

                    If reader.HasRows Then
                        While reader.Read()
                            Company.Text = reader.Item("Company").ToString
                            Address1.Text = reader.Item("Address1").ToString
                            Address2.Text = reader.Item("Address2").ToString
                            Phone.Text = reader.Item("Phone").ToString
                            FirstName.Text = reader.Item("FirstName").ToString()
                            LastName.Text = reader.Item("LastName").ToString()
                            City.Text = reader.Item("City").ToString()
                            State.Text = reader.Item("State").ToString()
                            Zip.Text = reader.Item("Zip").ToString()
                        End While
                    End If

                    reader.Close()
                Catch
                End Try

                bol = True

            End If

            cmd = New System.Data.SqlClient.SqlCommand("SELECT cusID, Company FROM Customers", conn)
        
            Try
                If Not conn.State = ConnectionState.Open Then conn.Open()
                reader = cmd.ExecuteReader()

                If reader.HasRows Then
                    DropDownList1.DataSource = reader
                    DropDownList1.DataTextField = "Company"
                    DropDownList1.DataValueField = "cusID"
                    DropDownList1.DataBind()
                    DropDownList1.Items.Insert(0, ("-- Choose a Company --"))
                    If bol = True Then DropDownList1.SelectedIndex = DropDownList1.Items.IndexOf(DropDownList1.Items.FindByValue(conID)))
                Else
                    DropDownList1.Items.Insert(0, ("-- Error: No Companies Found --")
                End If

                reader.Close()
                conn.Close()
            Catch
            End Try

            If conn.State = SqlConnection.ConnectionState.Open Then conn.Close()

    End If

    End Sub


    Protected Sub DropDownList1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DropDownList1.SelectedIndexChanged

        Dim FirstName As TextBox = TryCast(FormView1.FindControl("FirstName"), TextBox)
        Dim LastName As TextBox = TryCast(FormView1.FindControl("LastName"), TextBox)
        Dim DropDownListEquip As DropDownList = TryCast(FormView1.FindControl("DropDownListEquip"), DropDownList)

        Try
            cmd = New System.Data.SqlClient.SqlCommand("SELECT cusID, FirstName+ ' ' + LastName AS ContactName FROM Contacts WHERE cusID=@cusID ORDER BY LastName, FirstName", conn)
            cmd.Parameters.AddWithValue("@cusID", DropDownList1.SelectedValue)

            conn.Open()
            reader = cmd.ExecuteReader()

            If reader.HasRows Then
                DropDownList2.DataSource = reader
                DropDownList2.DataTextField = "ContactName"
                DropDownList2.DataValueField = "cusID"
                DropDownList2.DataBind()
                DropDownList2.Items.Insert(0, ("-- Choose a Contact --"))
            Else
                DropDownList2.Items.Insert(0, ("-- Error: No Contacts Found --")
            End If

            reader.Close()

            cmd = New System.Data.SqlClient.SqlCommand("SELECT a.Company + ' - ' + b.Description As CompanyEqpDesc, b.eqpID FROM Manufacturers a JOIN Equipment b ON a.mfgID=b.mfgID WHERE b.eqpID IN (SELECT eqpID FROM Cus_Equip WHERE cusID=@cusID", conn)
            cmd.Parameters.AddWithValue("@cusID", DropDownList1.SelectedValue)

            reader = cmd.ExecuteReader()

            If reader.HasRows Then
                DropDownListEquip.DataSource = reader
                DropDownListEquip.DataTextField = "CompanyEqpDesc"
                DropDownListEquip.DataValueField = "eqpID"
                DropDownListEquip.DataBind()
                DropDownListEquip.Items.Insert(0, ("-- Choose Equipment --"))
            Else
                DropDownListEquip.Items.Insert(0, ("-- Error: No Equipment Found --")
            End If

            reader.Close()
            conn.Close()
        Catch
        End Try

        FirstName.Text = ""
        LastName.Text = ""

    End Sub


    Protected Sub DropDownList2_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DropDownList2.SelectedIndexChanged

        Dim Company As TextBox = TryCast(FormView1.FindControl("Company"), TextBox)
        Dim Address1 As TextBox = TryCast(FormView1.FindControl("Address1"), TextBox)
        Dim Address2 As TextBox = TryCast(FormView1.FindControl("Address2"), TextBox)
        Dim Phone As TextBox = TryCast(FormView1.FindControl("Phone"), TextBox)
        Dim FirstName As TextBox = TryCast(FormView1.FindControl("FirstName"), TextBox)
        Dim LastName As TextBox = TryCast(FormView1.FindControl("LastName"), TextBox)
        Dim City As TextBox = TryCast(FormView1.FindControl("City"), TextBox)
        Dim State As TextBox = TryCast(FormView1.FindControl("State"), TextBox)
        Dim Zip As TextBox = TryCast(FormView1.FindControl("Zip"), TextBox)

        cmd = New System.Data.SqlClient.SqlCommand("SELECT a.Company, a.Address1, a.Address2, b.FirstName, b.LastName, c.City, c.State, c.Zip FROM Customers a JOIN Contacts b ON a.cusID=b.cusID JOIN Zip c ON a.cusID=c.cusID WHERE a.cusID=" & DropDownList1.SelectedValue, conn)

        Try
            conn.Open()
            reader = command.ExecuteReader()

            If reader.HasRows Then
                While reader.Read()
                    Company.Text = reader.Item("Company").ToString
                    Address1.Text = reader.Item("Address1").ToString
                    Address2.Text = reader.Item("Address2").ToString
                    Phone.Text = reader.Item("Phone").ToString
                    FirstName.Text = reader.Item("FirstName").ToString()
                    LastName.Text = reader.Item("LastName").ToString()
                    City.Text = reader.Item("City").ToString()
                    State.Text = reader.Item("State").ToString()
                    Zip.Text = reader.Item("Zip").ToString()
                End While
            End If

            reader.Close()
            conn.Close()
        Catch
        End Try

    End Sub


    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click

        Dim disID As String
        Dim recs As Integer = 0
        Dim Problem As TextBox = TryCast(FormView1.FindControl("Problem"), TextBox)
        Dim DropDownListPriority As DropDownList = TryCast(FormView1.FindControl("DropDownListPriority"), DropDownList)
        Dim DropDownListBill As DropDownList = TryCast(FormView1.FindControl("DropDownListBill"), DropDownList)

        cmd = New System.Data.SqlClient.SqlCommand("INSERT INTO Dispatch (cusID, Problem, Priority, Contract) VALUES (@cusID, @Problem, @Priority, @Contract); SELECT SCOPE_IDENTITY()", conn)
        cmd.Parameters.AddWithValue("@cusID", DropDownList1.SelectedValue)
        cmd.Parameters.AddWithValue("@Problem", Trim(Problem.Text))
        cmd.Parameters.AddWithValue("@Priority", DropDownListPriority.SelectedText)
        cmd.Parameters.AddWithValue("@Contract", DropDownListBill.SelectedText)

        Try
            conn.Open()
            disID = cmd.ExecuteScalar()

            cmd = New System.Data.SqlClient.SqlCommand("INSERT INTO DispatchEvents (disID, Notes) VALUES (@disID, @Notes)", conn)
            cmd.Parameters.AddWithValue("@disID", disID)
            cmd.Parameters.AddWithValue("@Notes", Trim(Notes.Text))

            recs = cmd.ExecuteNonQuery()
            conn.Close()

            If Len(disID) > 0 Then recs += 1

            If recs > 1 Then
                Response.Redirect("Dispatch.aspx")
            Else
                Response.Write("Recs Counted: " & recs & " out of 2.")
            End If
        Catch ex As System.Data.SqlClient.SqlException
            Response.Write(ex)
        End Try

    End Sub

End Class
0

Errors:

Line 51
'ExecuteReader' is not a member of 'String'.

Line 78:
Name 'ConnectionState' not declared

Line 97:
Name 'SqlConnection' not declared

Line 171:
'ExecuteReader' is not a member of 'String'.

Line 195:
Button1 ... requires WithEvents variable ...

Line 206 & 207:
'Selected Text' not a member of ....

Line 215:
Name 'Notes' not declared

0
Partial Class AddCall
    Inherits System.Web.UI.Page
    Protected WithEvents Button1_Click As Button

    Dim conn As New System.Data.SqlClient.SqlConnection("Data Source=IT-P02\SQLEXPRESS;Initial Catalog=HRIService;Integrated Security=True")
    Dim cmd As System.Data.SqlClient.SqlCommand
    Dim reader As System.Data.SqlClient.SqlDataReader
    Dim reader2 As System.Data.SqlClient.SqlDataReader

    Protected Sub Page_Load(ByVal S As Object, ByVal E As System.EventArgs)

    If Not Page.IsPostBack Then

            Dim bol As Boolean = False
            Dim conID As String = Trim(Request.QueryString("conID")).ToString()
            Dim cusID As String = Trim(Request.QueryString("cusID")).ToString()

            If Len(cusID) > 0 And Len(conID) > 0 Then

                Dim FirstName As TextBox = TryCast(FormView1.FindControl("FirstName"), TextBox)
                Dim LastName As TextBox = TryCast(FormView1.FindControl("LastName"), TextBox)
                Dim Company As TextBox = TryCast(FormView1.FindControl("Company"), TextBox)
                Dim Address1 As TextBox = TryCast(FormView1.FindControl("Address1"), TextBox)
                Dim Address2 As TextBox = TryCast(FormView1.FindControl("Address2"), TextBox)
                Dim Phone As TextBox = TryCast(FormView1.FindControl("Phone"), TextBox)
                Dim City As TextBox = TryCast(FormView1.FindControl("City"), TextBox)
                Dim State As TextBox = TryCast(FormView1.FindControl("State"), TextBox)
                Dim Zip As TextBox = TryCast(FormView1.FindControl("Zip"), TextBox)

                Try
                    cmd = New System.Data.SqlClient.SqlCommand("SELECT cusID, FirstName+ ' ' + LastName AS ContactName FROM Contacts WHERE cusID=@cusID ORDER BY LastName, FirstName", conn)
                    cmd.Parameters.AddWithValue("@cusID", cusID)

                    conn.Open()
                    reader = cmd.ExecuteReader()

                    If reader.HasRows Then
                        DropDownList2.DataSource = reader
                        DropDownList2.DataTextField = "ContactName"
                        DropDownList2.DataValueField = "cusID"
                        DropDownList2.DataBind()
                        DropDownList2.Items.Insert(0, ("-- Choose a Contact --"))
                        DropDownList2.SelectedIndex = DropDownList2.Items.IndexOf(DropDownList2.Items.FindByValue(conID))
                    Else
                        DropDownList2.Items.Insert(0, ("-- Error: No Contacts Found --")
                    End If

                    reader.Close()

                    cmd = New System.Data.SqlClient.SqlCommand("SELECT a.Company, a.Address1, a.Address2, b.FirstName, b.LastName, c.City, c.State, c.Zip FROM Customers a JOIN Contacts b ON a.cusID=b.cusID JOIN Zip c ON a.cusID=c.cusID WHERE a.cusID=@cusID and b.ContactID=@conID", conn)
                    cmd.Parameters.AddWithValue("@cusID", cusID)
                    cmd.Parameters.AddWithValue("@ContactID", conID)
                    reader2 = command.ExecuteReader()

                    If reader.HasRows Then
                        While reader.Read()
                            Company.Text = reader.Item("Company").ToString
                            Address1.Text = reader.Item("Address1").ToString
                            Address2.Text = reader.Item("Address2").ToString
                            Phone.Text = reader.Item("Phone").ToString
                            FirstName.Text = reader.Item("FirstName").ToString()
                            LastName.Text = reader.Item("LastName").ToString()
                            City.Text = reader.Item("City").ToString()
                            State.Text = reader.Item("State").ToString()
                            Zip.Text = reader.Item("Zip").ToString()
                        End While
                    End If

                    reader.Close()
                    conn.Close()
                Catch
                End Try

                bol = True

            End If

            cmd = New System.Data.SqlClient.SqlCommand("SELECT cusID, Company FROM Customers", conn)
        
            Try
                conn.Open()
                reader = cmd.ExecuteReader()

                If reader.HasRows Then
                    DropDownList1.DataSource = reader
                    DropDownList1.DataTextField = "Company"
                    DropDownList1.DataValueField = "cusID"
                    DropDownList1.DataBind()
                    DropDownList1.Items.Insert(0, ("-- Choose a Company --"))
                    If bol = True Then DropDownList1.SelectedIndex = DropDownList1.Items.IndexOf(DropDownList1.Items.FindByValue(conID)))
                Else
                    DropDownList1.Items.Insert(0, ("-- Error: No Companies Found --")
                End If

                reader.Close()
                conn.Close()
            Catch
            End Try

    End If

    End Sub


    Protected Sub DropDownList1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DropDownList1.SelectedIndexChanged

        Dim FirstName As TextBox = TryCast(FormView1.FindControl("FirstName"), TextBox)
        Dim LastName As TextBox = TryCast(FormView1.FindControl("LastName"), TextBox)
        Dim DropDownListEquip As DropDownList = TryCast(FormView1.FindControl("DropDownListEquip"), DropDownList)

        Try
            cmd = New System.Data.SqlClient.SqlCommand("SELECT cusID, FirstName+ ' ' + LastName AS ContactName FROM Contacts WHERE cusID=@cusID ORDER BY LastName, FirstName", conn)
            cmd.Parameters.AddWithValue("@cusID", DropDownList1.SelectedValue)

            conn.Open()
            reader = cmd.ExecuteReader()

            If reader.HasRows Then
                DropDownList2.DataSource = reader
                DropDownList2.DataTextField = "ContactName"
                DropDownList2.DataValueField = "cusID"
                DropDownList2.DataBind()
                DropDownList2.Items.Insert(0, ("-- Choose a Contact --"))
            Else
                DropDownList2.Items.Insert(0, ("-- Error: No Contacts Found --")
            End If

            reader.Close()

            cmd = New System.Data.SqlClient.SqlCommand("SELECT a.Company + ' - ' + b.Description As CompanyEqpDesc, b.eqpID FROM Manufacturers a JOIN Equipment b ON a.mfgID=b.mfgID WHERE b.eqpID IN (SELECT eqpID FROM Cus_Equip WHERE cusID=@cusID", conn)
            cmd.Parameters.AddWithValue("@cusID", DropDownList1.SelectedValue)

            reader2 = cmd.ExecuteReader()

            If reader.HasRows Then
                DropDownListEquip.DataSource = reader
                DropDownListEquip.DataTextField = "CompanyEqpDesc"
                DropDownListEquip.DataValueField = "eqpID"
                DropDownListEquip.DataBind()
                DropDownListEquip.Items.Insert(0, ("-- Choose Equipment --"))
            Else
                DropDownListEquip.Items.Insert(0, ("-- Error: No Equipment Found --")
            End If

            reader.Close()
            conn.Close()
        Catch
        End Try

        FirstName.Text = ""
        LastName.Text = ""

    End Sub


    Protected Sub DropDownList2_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DropDownList2.SelectedIndexChanged

        Dim Company As TextBox = TryCast(FormView1.FindControl("Company"), TextBox)
        Dim Address1 As TextBox = TryCast(FormView1.FindControl("Address1"), TextBox)
        Dim Address2 As TextBox = TryCast(FormView1.FindControl("Address2"), TextBox)
        Dim Phone As TextBox = TryCast(FormView1.FindControl("Phone"), TextBox)
        Dim FirstName As TextBox = TryCast(FormView1.FindControl("FirstName"), TextBox)
        Dim LastName As TextBox = TryCast(FormView1.FindControl("LastName"), TextBox)
        Dim City As TextBox = TryCast(FormView1.FindControl("City"), TextBox)
        Dim State As TextBox = TryCast(FormView1.FindControl("State"), TextBox)
        Dim Zip As TextBox = TryCast(FormView1.FindControl("Zip"), TextBox)

        cmd = New System.Data.SqlClient.SqlCommand("SELECT a.Company, a.Address1, a.Address2, b.FirstName, b.LastName, c.City, c.State, c.Zip FROM Customers a JOIN Contacts b ON a.cusID=b.cusID JOIN Zip c ON a.cusID=c.cusID WHERE a.cusID=" & DropDownList1.SelectedValue, conn)

        Try
            conn.Open()
            reader = command.ExecuteReader()

            If reader.HasRows Then
                While reader.Read()
                    Company.Text = reader.Item("Company").ToString
                    Address1.Text = reader.Item("Address1").ToString
                    Address2.Text = reader.Item("Address2").ToString
                    Phone.Text = reader.Item("Phone").ToString
                    FirstName.Text = reader.Item("FirstName").ToString()
                    LastName.Text = reader.Item("LastName").ToString()
                    City.Text = reader.Item("City").ToString()
                    State.Text = reader.Item("State").ToString()
                    Zip.Text = reader.Item("Zip").ToString()
                End While
            End If

            reader.Close()
            conn.Close()
        Catch
        End Try

    End Sub


    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click

        Dim disID As String
        Dim recs As Integer = 0
        Dim Problem As TextBox = TryCast(FormView1.FindControl("Problem"), TextBox)
        Dim DropDownListPriority As DropDownList = TryCast(FormView1.FindControl("DropDownListPriority"), DropDownList)
        Dim DropDownListBill As DropDownList = TryCast(FormView1.FindControl("DropDownListBill"), DropDownList)
        Dim Notes As TextBox = TryCast(FormView1.FindControl("Notes"), TextBox)

        cmd = New System.Data.SqlClient.SqlCommand("INSERT INTO Dispatch (cusID, Problem, Priority, Contract) VALUES (@cusID, @Problem, @Priority, @Contract); SELECT SCOPE_IDENTITY()", conn)
        cmd.Parameters.AddWithValue("@cusID", DropDownList1.SelectedItem.Value)
        cmd.Parameters.AddWithValue("@Problem", Trim(Problem.Text))
        cmd.Parameters.AddWithValue("@Priority", DropDownListPriority.SelectedItem.Text)
        cmd.Parameters.AddWithValue("@Contract", DropDownListBill.SelectedItem.Text)

        Try
            conn.Open()
            disID = cmd.ExecuteScalar()

            cmd = New System.Data.SqlClient.SqlCommand("INSERT INTO DispatchEvents (disID, Notes) VALUES (@disID, @Notes)", conn)
            cmd.Parameters.AddWithValue("@disID", disID)
            cmd.Parameters.AddWithValue("@Notes", Trim(Notes.Text))

            recs = cmd.ExecuteNonQuery()
            conn.Close()

            If Len(disID) > 0 Then recs += 1

            If recs > 1 Then
                Response.Redirect("Dispatch.aspx")
            Else
                Response.Write("Recs Counted: " & recs & " out of 2.")
            End If
        Catch ex As System.Data.SqlClient.SqlException
            Response.Write(ex)
        End Try

    End Sub

End Class
0

Server Error in '/HRIService' Application.
Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: BC30456: 'ExecuteReader' is not a member of 'String'.

Source Error:

Line 51: cmd.Parameters.AddWithValue("@cusID", cusID)
Line 52: cmd.Parameters.AddWithValue("@ContactID", conID)
Line 53: reader2 = command.ExecuteReader()
Line 54:
Line 55: If reader.HasRows Then


Source File: C:\Inetpub\wwwroot\HRIService\ServiceExpress\AddCall.aspx.vb Line: 53

0

There were some errors with parentheses that I fixed. Here is a new one:

Server Error in '/HRIService' Application.
Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: BC30260: 'Button1_Click' is already declared as 'Protected WithEvents Button1_Click As System.Web.UI.WebControls.Button' in this class.

Source Error:

Line 194:
Line 195:
Line 196: Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Line 197:
Line 198: Dim disID As String


Source File: C:\Inetpub\wwwroot\HRIService\ServiceExpress\AddCall.aspx.vb Line: 196

0

Server Error in '/HRIService' Application.
Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: BC30506: Handles clause requires a WithEvents variable defined in the containing type or one of its base types.

Source Error:

Line 193:
Line 194:
Line 195: Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Line 196:
Line 197: Dim disID As String


Source File: C:\Inetpub\wwwroot\HRIService\ServiceExpress\AddCall.aspx.vb Line: 195

0

Server Error in '/HRIService' Application.
Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: BC30242: 'WithEvents' is not valid on a method declaration.

Source Error:

Line 193:
Line 194:
Line 195: Protected WithEvents Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Line 196:
Line 197: Dim disID As String


Source File: C:\Inetpub\wwwroot\HRIService\ServiceExpress\AddCall.aspx.vb Line: 195

0

I had it right the first time. put this at the top of the thing, and remove that withevents from the sub:

Protected WithEvents Button1 As Button

0

The DataSourceID of 'FormView1' must be the ID of a control of type IDataSource. A control with ID 'SqlDataSource4' could not be found.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Web.HttpException: The DataSourceID of 'FormView1' must be the ID of a control of type IDataSource. A control with ID 'SqlDataSource4' could not be found.

0

Ok, I removed the datasource from formview. The page is up but there is nothing populating the ddls. Also, add customer doesn't populate ddls.

0

Add this right after the end of your FormView.
Add after </asp:FormView>

<asp:SqlDataSource ID="SqlDataSource4" runat="server"></asp:SqlDataSource>
0

That was part of it. It didn't populate the contact fields in the form or the eqp ddl.

0

Post me the code that you have now, so we are on the same track.

Also, explain to me how you got there submitted company or what

0

code behind

Partial Class AddCall
    Inherits System.Web.UI.Page
    Protected WithEvents Button1 As Button

    Dim conn As New System.Data.SqlClient.SqlConnection("Data Source=IT-P02\SQLEXPRESS;Initial Catalog=HRIService;Integrated Security=True")
    Dim cmd As System.Data.SqlClient.SqlCommand
    Dim reader As System.Data.SqlClient.SqlDataReader
    Dim reader2 As System.Data.SqlClient.SqlDataReader

    Protected Sub Page_Load(ByVal S As Object, ByVal E As System.EventArgs)

        If Not Page.IsPostBack Then

            Dim bol As Boolean = False
            Dim conID As String = Trim(Request.QueryString("conID")).ToString()
            Dim cusID As String = Trim(Request.QueryString("cusID")).ToString()

            If Len(cusID) > 0 And Len(conID) > 0 Then

                Dim FirstName As TextBox = TryCast(FormView1.FindControl("FirstName"), TextBox)
                Dim LastName As TextBox = TryCast(FormView1.FindControl("LastName"), TextBox)
                Dim Company As TextBox = TryCast(FormView1.FindControl("Company"), TextBox)
                Dim Address1 As TextBox = TryCast(FormView1.FindControl("Address1"), TextBox)
                Dim Address2 As TextBox = TryCast(FormView1.FindControl("Address2"), TextBox)
                Dim Phone As TextBox = TryCast(FormView1.FindControl("Phone"), TextBox)
                Dim City As TextBox = TryCast(FormView1.FindControl("City"), TextBox)
                Dim State As TextBox = TryCast(FormView1.FindControl("State"), TextBox)
                Dim Zip As TextBox = TryCast(FormView1.FindControl("Zip"), TextBox)

                Try
                    cmd = New System.Data.SqlClient.SqlCommand("SELECT cusID, FirstName+ ' ' + LastName AS ContactName FROM Contacts WHERE cusID=@cusID ORDER BY LastName, FirstName", conn)
                    cmd.Parameters.AddWithValue("@cusID", cusID)

                    conn.Open()
                    reader = cmd.ExecuteReader()

                    If reader.HasRows Then
                        DropDownList2.DataSource = reader
                        DropDownList2.DataTextField = "ContactName"
                        DropDownList2.DataValueField = "cusID"
                        DropDownList2.DataBind()
                        DropDownList2.Items.Insert(0, ("-- Choose a Contact --"))
                        DropDownList2.SelectedIndex = DropDownList2.Items.IndexOf(DropDownList2.Items.FindByValue(conID))
                    Else
                        DropDownList2.Items.Insert(0, ("-- Error: No Contacts Found --"))
                    End If

                    reader.Close()

                    cmd = New System.Data.SqlClient.SqlCommand("SELECT a.Company, a.Address1, a.Address2, b.FirstName, b.LastName, c.City, c.State, c.Zip FROM Customers a JOIN Contacts b ON a.cusID=b.cusID JOIN Zip c ON a.cusID=c.cusID WHERE a.cusID=@cusID and b.ContactID=@conID", conn)
                    cmd.Parameters.AddWithValue("@cusID", cusID)
                    cmd.Parameters.AddWithValue("@ContactID", conID)
                    reader2 = cmd.ExecuteReader()

                    If reader.HasRows Then
                        While reader.Read()
                            Company.Text = reader.Item("Company").ToString
                            Address1.Text = reader.Item("Address1").ToString
                            Address2.Text = reader.Item("Address2").ToString
                            Phone.Text = reader.Item("Phone").ToString
                            FirstName.Text = reader.Item("FirstName").ToString()
                            LastName.Text = reader.Item("LastName").ToString()
                            City.Text = reader.Item("City").ToString()
                            State.Text = reader.Item("State").ToString()
                            Zip.Text = reader.Item("Zip").ToString()
                        End While
                    End If

                    reader.Close()
                    conn.Close()
                Catch
                End Try

                bol = True

            End If

            cmd = New System.Data.SqlClient.SqlCommand("SELECT cusID, Company FROM Customers", conn)

            Try
                conn.Open()
                reader = cmd.ExecuteReader()

                If reader.HasRows Then
                    DropDownList1.DataSource = reader
                    DropDownList1.DataTextField = "Company"
                    DropDownList1.DataValueField = "cusID"
                    DropDownList1.DataBind()
                    DropDownList1.Items.Insert(0, ("-- Choose a Company --"))
                    If bol = True Then DropDownList1.SelectedIndex = DropDownList1.Items.IndexOf(DropDownList1.Items.FindByValue(conID))
                Else
                    DropDownList1.Items.Insert(0, ("-- Error: No Companies Found --"))
                End If

                reader.Close()
                conn.Close()
            Catch
            End Try

        End If

    End Sub


    Protected Sub DropDownList1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DropDownList1.SelectedIndexChanged

        Dim FirstName As TextBox = TryCast(FormView1.FindControl("FirstName"), TextBox)
        Dim LastName As TextBox = TryCast(FormView1.FindControl("LastName"), TextBox)
        Dim DropDownListEquip As DropDownList = TryCast(FormView1.FindControl("DropDownListEquip"), DropDownList)

        Try
            cmd = New System.Data.SqlClient.SqlCommand("SELECT cusID, FirstName+ ' ' + LastName AS ContactName FROM Contacts WHERE cusID=@cusID ORDER BY LastName, FirstName", conn)
            cmd.Parameters.AddWithValue("@cusID", DropDownList1.SelectedValue)

            conn.Open()
            reader = cmd.ExecuteReader()

            If reader.HasRows Then
                DropDownList2.DataSource = reader
                DropDownList2.DataTextField = "ContactName"
                DropDownList2.DataValueField = "cusID"
                DropDownList2.DataBind()
                DropDownList2.Items.Insert(0, ("-- Choose a Contact --"))
            Else
                DropDownList2.Items.Insert(0, ("-- Error: No Contacts Found --"))
            End If

            reader.Close()

            cmd = New System.Data.SqlClient.SqlCommand("SELECT a.Company + ' - ' + b.Description As CompanyEqpDesc, b.eqpID FROM Manufacturers a JOIN Equipment b ON a.mfgID=b.mfgID WHERE b.eqpID IN (SELECT eqpID FROM Cus_Equip WHERE cusID=@cusID", conn)
            cmd.Parameters.AddWithValue("@cusID", DropDownList1.SelectedValue)

            reader2 = cmd.ExecuteReader()

            If reader.HasRows Then
                DropDownListEquip.DataSource = reader
                DropDownListEquip.DataTextField = "CompanyEqpDesc"
                DropDownListEquip.DataValueField = "eqpID"
                DropDownListEquip.DataBind()
                DropDownListEquip.Items.Insert(0, ("-- Choose Equipment --"))
            Else
                DropDownListEquip.Items.Insert(0, ("-- Error: No Equipment Found --"))
            End If

            reader.Close()
            conn.Close()
        Catch
        End Try

        FirstName.Text = ""
        LastName.Text = ""

    End Sub


    Protected Sub DropDownList2_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DropDownList2.SelectedIndexChanged

        Dim Company As TextBox = TryCast(FormView1.FindControl("Company"), TextBox)
        Dim Address1 As TextBox = TryCast(FormView1.FindControl("Address1"), TextBox)
        Dim Address2 As TextBox = TryCast(FormView1.FindControl("Address2"), TextBox)
        Dim Phone As TextBox = TryCast(FormView1.FindControl("Phone"), TextBox)
        Dim FirstName As TextBox = TryCast(FormView1.FindControl("FirstName"), TextBox)
        Dim LastName As TextBox = TryCast(FormView1.FindControl("LastName"), TextBox)
        Dim City As TextBox = TryCast(FormView1.FindControl("City"), TextBox)
        Dim State As TextBox = TryCast(FormView1.FindControl("State"), TextBox)
        Dim Zip As TextBox = TryCast(FormView1.FindControl("Zip"), TextBox)

        cmd = New System.Data.SqlClient.SqlCommand("SELECT a.Company, a.Address1, a.Address2, b.FirstName, b.LastName, c.City, c.State, c.Zip FROM Customers a JOIN Contacts b ON a.cusID=b.cusID JOIN Zip c ON a.cusID=c.cusID WHERE a.cusID=" & DropDownList1.SelectedValue, conn)

        Try
            conn.Open()
            reader = cmd.ExecuteReader()

            If reader.HasRows Then
                While reader.Read()
                    Company.Text = reader.Item("Company").ToString
                    Address1.Text = reader.Item("Address1").ToString
                    Address2.Text = reader.Item("Address2").ToString
                    Phone.Text = reader.Item("Phone").ToString
                    FirstName.Text = reader.Item("FirstName").ToString()
                    LastName.Text = reader.Item("LastName").ToString()
                    City.Text = reader.Item("City").ToString()
                    State.Text = reader.Item("State").ToString()
                    Zip.Text = reader.Item("Zip").ToString()
                End While
            End If

            reader.Close()
            conn.Close()
        Catch
        End Try

    End Sub


    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click

        Dim disID As String
        Dim recs As Integer = 0
        Dim Problem As TextBox = TryCast(FormView1.FindControl("Problem"), TextBox)
        Dim DropDownListPriority As DropDownList = TryCast(FormView1.FindControl("DropDownListPriority"), DropDownList)
        Dim DropDownListBill As DropDownList = TryCast(FormView1.FindControl("DropDownListBill"), DropDownList)
        Dim Notes As TextBox = TryCast(FormView1.FindControl("Notes"), TextBox)

        cmd = New System.Data.SqlClient.SqlCommand("INSERT INTO Dispatch (cusID, Problem, Priority, Contract) VALUES (@cusID, @Problem, @Priority, @Contract); SELECT SCOPE_IDENTITY()", conn)
        cmd.Parameters.AddWithValue("@cusID", DropDownList1.SelectedItem.Value)
        cmd.Parameters.AddWithValue("@Problem", Trim(Problem.Text))
        cmd.Parameters.AddWithValue("@Priority", DropDownListPriority.SelectedItem.Text)
        cmd.Parameters.AddWithValue("@Contract", DropDownListBill.SelectedItem.Text)

        Try
            conn.Open()
            disID = cmd.ExecuteScalar()

            cmd = New System.Data.SqlClient.SqlCommand("INSERT INTO DispatchEvents (disID, Notes) VALUES (@disID, @Notes)", conn)
            cmd.Parameters.AddWithValue("@disID", disID)
            cmd.Parameters.AddWithValue("@Notes", Trim(Notes.Text))

            recs = cmd.ExecuteNonQuery()
            conn.Close()

            If Len(disID) > 0 Then recs += 1

            If recs > 1 Then
                Response.Redirect("Dispatch.aspx")
            Else
                Response.Write("Recs Counted: " & recs & " out of 2.")
            End If
        Catch ex As System.Data.SqlClient.SqlException
            Response.Write(ex)
        End Try

    End Sub

End Class

Some of the info I directly entered into the db, otherwise I've been using the DisAddCo.aspx page to test and it has added several.

0

Tell me what you did to test this:

Did you just start the page, choose a company, then got errors?

or

Did you create the customer, and automatically been redirected to this page?

0

To test this last update I just went to the AddCall.aspx page and selected a company and contact. Then it did not populate contact fields or eqp dll.

0

Also, I just noticed it is not posting info from the Zip table ... city, state, and zip.

0

A few little errors that won't post an error, but will prevent code execution.

Partial Class AddCall
    Inherits System.Web.UI.Page
    Protected WithEvents Button1_Click As Button

    Dim conn As New System.Data.SqlClient.SqlConnection("Data Source=IT-P02\SQLEXPRESS;Initial Catalog=HRIService;Integrated Security=True")
    Dim cmd As System.Data.SqlClient.SqlCommand
    Dim reader As System.Data.SqlClient.SqlDataReader
    Dim reader2 As System.Data.SqlClient.SqlDataReader

    Protected Sub Page_Load(ByVal S As Object, ByVal E As System.EventArgs)

    If Not Page.IsPostBack Then

            Dim bol As Boolean = False
            Dim conID As String = Trim(Request.QueryString("conID")).ToString()
            Dim cusID As String = Trim(Request.QueryString("cusID")).ToString()

            If Len(cusID) > 0 And Len(conID) > 0 Then

                Dim FirstName As TextBox = TryCast(FormView1.FindControl("FirstName"), TextBox)
                Dim LastName As TextBox = TryCast(FormView1.FindControl("LastName"), TextBox)
                Dim Company As TextBox = TryCast(FormView1.FindControl("Company"), TextBox)
                Dim Address1 As TextBox = TryCast(FormView1.FindControl("Address1"), TextBox)
                Dim Address2 As TextBox = TryCast(FormView1.FindControl("Address2"), TextBox)
                Dim Phone As TextBox = TryCast(FormView1.FindControl("Phone"), TextBox)
                Dim City As TextBox = TryCast(FormView1.FindControl("City"), TextBox)
                Dim State As TextBox = TryCast(FormView1.FindControl("State"), TextBox)
                Dim Zip As TextBox = TryCast(FormView1.FindControl("Zip"), TextBox)

                Try
                    cmd = New System.Data.SqlClient.SqlCommand("SELECT cusID, FirstName+ ' ' + LastName AS ContactName FROM Contacts WHERE cusID=@cusID ORDER BY LastName, FirstName", conn)
                    cmd.Parameters.AddWithValue("@cusID", cusID)

                    conn.Open()
                    reader = cmd.ExecuteReader()

                    If reader.HasRows Then
                        DropDownList2.DataSource = reader
                        DropDownList2.DataTextField = "ContactName"
                        DropDownList2.DataValueField = "cusID"
                        DropDownList2.DataBind()
                        DropDownList2.Items.Insert(0, ("-- Choose a Contact --"))
                        DropDownList2.SelectedIndex = DropDownList2.Items.IndexOf(DropDownList2.Items.FindByValue(conID))
                    Else
                        DropDownList2.Items.Insert(0, ("-- Error: No Contacts Found --")
                    End If

                    reader.Close()

                    cmd = New System.Data.SqlClient.SqlCommand("SELECT a.Company, a.Address1, a.Address2, b.FirstName, b.LastName, c.City, c.State, c.Zip FROM Customers a JOIN Contacts b ON a.cusID=b.cusID JOIN Zip c ON a.cusID=c.cusID WHERE a.cusID=@cusID and b.ContactID=@conID", conn)
                    cmd.Parameters.AddWithValue("@cusID", cusID)
                    cmd.Parameters.AddWithValue("@ContactID", conID)
                    reader2 = command.ExecuteReader()

                    If reader.HasRows Then
                        While reader.Read()
                            Company.Text = reader.Item("Company").ToString
                            Address1.Text = reader.Item("Address1").ToString
                            Address2.Text = reader.Item("Address2").ToString
                            Phone.Text = reader.Item("Phone").ToString
                            FirstName.Text = reader.Item("FirstName").ToString()
                            LastName.Text = reader.Item("LastName").ToString()
                            City.Text = reader.Item("City").ToString()
                            State.Text = reader.Item("State").ToString()
                            Zip.Text = reader.Item("Zip").ToString()
                        End While
                    End If

                    reader.Close()
                    conn.Close()
                Catch
                End Try

                bol = True

            End If

            cmd = New System.Data.SqlClient.SqlCommand("SELECT cusID, Company FROM Customers", conn)
        
            Try
                conn.Open()
                reader = cmd.ExecuteReader()

                If reader.HasRows Then
                    DropDownList1.DataSource = reader
                    DropDownList1.DataTextField = "Company"
                    DropDownList1.DataValueField = "cusID"
                    DropDownList1.DataBind()
                    DropDownList1.Items.Insert(0, ("-- Choose a Company --"))
                    If bol = True Then DropDownList1.SelectedIndex = DropDownList1.Items.IndexOf(DropDownList1.Items.FindByValue(conID)))
                Else
                    DropDownList1.Items.Insert(0, ("-- Error: No Companies Found --")
                End If

                reader.Close()
                conn.Close()
            Catch
            End Try

    End If

    End Sub


    Protected Sub DropDownList1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DropDownList1.SelectedIndexChanged

        Dim FirstName As TextBox = TryCast(FormView1.FindControl("FirstName"), TextBox)
        Dim LastName As TextBox = TryCast(FormView1.FindControl("LastName"), TextBox)
        Dim DropDownListEquip As DropDownList = TryCast(FormView1.FindControl("DropDownListEquip"), DropDownList)
        Dim DropDownList1 As DropDownList = TryCast(FormView1.FindControl("DropDownList1"), DropDownList)

        Try
            cmd = New System.Data.SqlClient.SqlCommand("SELECT cusID, FirstName+ ' ' + LastName AS ContactName FROM Contacts WHERE cusID=@cusID ORDER BY LastName, FirstName", conn)
            cmd.Parameters.AddWithValue("@cusID", DropDownList1.SelectedIndex.Value)

            conn.Open()
            reader = cmd.ExecuteReader()

            If reader.HasRows Then
                DropDownList2.DataSource = reader
                DropDownList2.DataTextField = "ContactName"
                DropDownList2.DataValueField = "cusID"
                DropDownList2.DataBind()
                DropDownList2.Items.Insert(0, ("-- Choose a Contact --"))
            Else
                DropDownList2.Items.Insert(0, ("-- Error: No Contacts Found --")
            End If

            reader.Close()

            cmd = New System.Data.SqlClient.SqlCommand("SELECT a.Company + ' - ' + b.Description As CompanyEqpDesc, b.eqpID FROM Manufacturers a JOIN Equipment b ON a.mfgID=b.mfgID WHERE b.eqpID IN (SELECT eqpID FROM Cus_Equip WHERE cusID=@cusID)", conn)
            cmd.Parameters.AddWithValue("@cusID", DropDownList1.SelectedIndex.Value)

            reader2 = cmd.ExecuteReader()

            If reader.HasRows Then
                DropDownListEquip.DataSource = reader
                DropDownListEquip.DataTextField = "CompanyEqpDesc"
                DropDownListEquip.DataValueField = "eqpID"
                DropDownListEquip.DataBind()
                DropDownListEquip.Items.Insert(0, ("-- Choose Equipment --"))
            Else
                DropDownListEquip.Items.Insert(0, ("-- Error: No Equipment Found --")
            End If

            reader.Close()
            conn.Close()
        Catch
        End Try

        FirstName.Text = ""
        LastName.Text = ""

    End Sub


    Protected Sub DropDownList2_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DropDownList2.SelectedIndexChanged

        Dim Company As TextBox = TryCast(FormView1.FindControl("Company"), TextBox)
        Dim Address1 As TextBox = TryCast(FormView1.FindControl("Address1"), TextBox)
        Dim Address2 As TextBox = TryCast(FormView1.FindControl("Address2"), TextBox)
        Dim Phone As TextBox = TryCast(FormView1.FindControl("Phone"), TextBox)
        Dim FirstName As TextBox = TryCast(FormView1.FindControl("FirstName"), TextBox)
        Dim LastName As TextBox = TryCast(FormView1.FindControl("LastName"), TextBox)
        Dim City As TextBox = TryCast(FormView1.FindControl("City"), TextBox)
        Dim State As TextBox = TryCast(FormView1.FindControl("State"), TextBox)
        Dim Zip As TextBox = TryCast(FormView1.FindControl("Zip"), TextBox)
        Dim DropDownList1 As DropDownList = TryCast(FormView1.FindControl("DropDownList1"), DropDownList)

        cmd = New System.Data.SqlClient.SqlCommand("SELECT a.Company, a.Address1, a.Address2, b.FirstName, b.LastName, c.City, c.State, c.Zip FROM Customers a JOIN Contacts b ON a.cusID=b.cusID JOIN Zip c ON a.cusID=c.cusID WHERE a.cusID=@cusID and b.ContactID=@conID", conn)
        cmd.Parameters.AddWithValue("@cusID", DropDownList1.SelectedIndex.Value )
        cmd.Parameters.AddWithValue("@conID", DropDownList2.SelectedIndex.Value )

        Try
            conn.Open()
            reader = command.ExecuteReader()

            If reader.HasRows Then
                While reader.Read()
                    Company.Text = reader.Item("Company").ToString
                    Address1.Text = reader.Item("Address1").ToString
                    Address2.Text = reader.Item("Address2").ToString
                    Phone.Text = reader.Item("Phone").ToString
                    FirstName.Text = reader.Item("FirstName").ToString()
                    LastName.Text = reader.Item("LastName").ToString()
                    City.Text = reader.Item("City").ToString()
                    State.Text = reader.Item("State").ToString()
                    Zip.Text = reader.Item("Zip").ToString()
                End While
            End If

            reader.Close()
            conn.Close()
        Catch
        End Try

    End Sub


    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click

        Dim disID As String
        Dim recs As Integer = 0
        Dim Problem As TextBox = TryCast(FormView1.FindControl("Problem"), TextBox)
        Dim DropDownListPriority As DropDownList = TryCast(FormView1.FindControl("DropDownListPriority"), DropDownList)
        Dim DropDownListBill As DropDownList = TryCast(FormView1.FindControl("DropDownListBill"), DropDownList)
        Dim Notes As TextBox = TryCast(FormView1.FindControl("Notes"), TextBox)

        cmd = New System.Data.SqlClient.SqlCommand("INSERT INTO Dispatch (cusID, Problem, Priority, Contract) VALUES (@cusID, @Problem, @Priority, @Contract); SELECT SCOPE_IDENTITY()", conn)
        cmd.Parameters.AddWithValue("@cusID", DropDownList1.SelectedItem.Value)
        cmd.Parameters.AddWithValue("@Problem", Trim(Problem.Text))
        cmd.Parameters.AddWithValue("@Priority", DropDownListPriority.SelectedItem.Text)
        cmd.Parameters.AddWithValue("@Contract", DropDownListBill.SelectedItem.Text)

        Try
            conn.Open()
            disID = cmd.ExecuteScalar()

            cmd = New System.Data.SqlClient.SqlCommand("INSERT INTO DispatchEvents (disID, Notes) VALUES (@disID, @Notes)", conn)
            cmd.Parameters.AddWithValue("@disID", disID)
            cmd.Parameters.AddWithValue("@Notes", Trim(Notes.Text))

            recs = cmd.ExecuteNonQuery()
            conn.Close()

            If Len(disID) > 0 Then recs += 1

            If recs > 1 Then
                Response.Redirect("Dispatch.aspx")
            Else
                Response.Write("Recs Counted: " & recs & " out of 2.")
            End If
        Catch ex As System.Data.SqlClient.SqlException
            Response.Write(ex)
        End Try

    End Sub

End Class
0

Server Error in '/HRIService' Application.
Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: BC30456: 'Value' is not a member of 'Integer'.

Source Error:

Line 112: Try
Line 113: cmd = New System.Data.SqlClient.SqlCommand("SELECT cusID, FirstName+ ' ' + LastName AS ContactName FROM Contacts WHERE cusID=@cusID ORDER BY LastName, FirstName", conn)
Line 114: cmd.Parameters.AddWithValue("@cusID", DropDownList1.SelectedIndex.Value)
Line 115:
Line 116: conn.Open()


Source File: C:\Inetpub\wwwroot\HRIService\ServiceExpress\AddCall.aspx.vb Line: 114

0

Okay do a simple search and replace all of this:

SelectedIndex.Value

to

SelectedIndex.Value.ToString()

If that fails, then make all those into:

SelectedValue

0

I haven't hit half of these problems in coding and I have built much more interactive and complex sites and programs. This is why I do not deal with code-behind. ^^

I'll convert, and probably not long from now. But till then, I love my inline-coding.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.