Click here to Skip to main content
15,892,298 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi
I have an issue when generate class file, error "Input string was not in a correct format"
Pls advice me

It is my class.vb file

HTML
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 my asp.page

HTML
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
Posted
Comments
[no name] 15-Aug-14 23:08pm    
You don't say where you are getting this error but it means exactly what it says. On another note, what is it that you would expect loaddata = data.Read to do? SqlDataReader.Read does not return a string.
PhilLenoir 18-Aug-14 11:09am    
I'm not sure what putting your stored proc name in brackets would do, but you don't need them (cmd.Text = "xx" not cmd.Text =("xx").)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900