0

Hi
I have an issue when generate class file, error "Input string was not in a correct format"
Pls advice me
Thank you
Maideen

It is my class.vb file

 Public Function loaddata(inID As Integer, inname As String, inaddress As String, intel As String, infax As String, inemail As String, inregno As String) As String
        '
        Dim data As SqlDataReader
        Dim cmd As New SqlCommand
        cmd = New SqlCommand
        cmd.Connection = conn
        cmd.CommandText = ("usp_CompanyInfo_SelectAll")
        cmd.CommandType = CommandType.StoredProcedure

        loaddata = String.Empty

        conn.Open()
        data = cmd.ExecuteReader()
        loaddata = data.Read
        Try
            inID = data.Item("id")
            inname = data.Item("name")
            inaddress = data.Item("address")
            intel = data.Item("TelNo")
            infax = data.Item("FaxNo")
            inemail = data.Item("email")
            inregno = data.Item("RegNo")

            cmd.Dispose()
            conn.Close()
        Catch ex As Exception
            loaddata = ex.Message.ToString
            conn.Close()
        Finally
            cmd.Dispose()
            conn.Close()
        End Try
        Return loaddata
    End Function

It is asp.page

  Private Sub loaddata()
        Dim errmsg As String
        errmsg = clsCompany.loaddata(Me.txtID.Text, Me.txtName.Text, Me.txtAddress.Text, Me.txtTelNo.Text, Me.txtFaxNo.Text, Me.txtEmail.Text, Me.txtRegNo.Text)

        If errmsg <> String.Empty Then
            ScriptManager.RegisterStartupScript(Me, Me.[GetType](), "Message", "alert('Error occured : " & errmsg & "');", True)
        Else
            ClearALL()
            ScriptManager.RegisterStartupScript(Page, Page.GetType(), "alert", "alert('Record Saved !');", True)

        End If
    End Sub
3
Contributors
2
Replies
19
Views
3 Years
Discussion Span
Last Post by ashishggits
0

Hi,
Put a breakpoint and step into the class in Visual Studio and try to find which line throws the error. Also check the field names enclosed in double quotes between lines 16 and 22 in your code.

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.