Input string was not in a correct format. mscorlib
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: Input string was not in a correct format. mscorlib

  1. #1
    Join Date
    Dec 2002
    Location
    Kyrgyzstan
    Posts
    181

    Input string was not in a correct format. mscorlib

    ex.Message = Input string was not in a correct format. ex.Source = mscorlib

    at the following line I have that error message,
    what that problem is ??
    Dim GetRow As DataRow = DataSet99.Tables("Documents").Rows.Find(searchPart)

    Code:
    Private Sub Search_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Search.Click
              If IsValid Then
                  Try
                      SqlConnection1.Open()
                      Dim searchPart As String = txtName.Text
                      Dim DataAdapter1 As New SqlClient.SqlDataAdapter("Select * From Documents", SqlConnection1)
                      Dim Command As New SqlClient.SqlCommandBuilder(DataAdapter1)                        Dim DataSet99 As New DataSet
                      DataSet99.Clear()
                      DataAdapter1.Fill(DataSet99, "Documents")
                        Dim keys(1) As DataColumn
                      keys(0) = DataSet99.Tables("Documents").Columns("id_doc")
                      DataSet99.Tables("Documents").PrimaryKey = keys
                        'Dim NameS = "id_doc ='" & searchPart & "'"                  
                      Dim GetRow As DataRow = DataSet99.Tables("Documents").Rows.Find(searchPart)
                        txtInNum.Text = GetRow("cod_int")
                      txtExNum.Text = GetRow("cod_ext")
                      SqlConnection1.Close()
                  Catch ex As Exception
                      ErrorMsg.Text = ex.Message & " " & ex.Source
                      ErrorMsg.Visible = True
                  End Try
              End If
          End Sub
    Best regards
    Exceter.

  2. #2
    Join Date
    May 2002
    Location
    Russia
    Posts
    1,571
    at the following line I have that error message,
    what that problem is ??
    The problem is your searchPart is not correct. You should pass to find method the primary key value. For example
    Code:
    table.Rows.Find(10)

  3. #3
    Join Date
    Dec 2002
    Location
    Kyrgyzstan
    Posts
    181
    Quote Originally Posted by alexey_1979
    The problem is your searchPart is not correct. You should pass to find method the primary key value.
    In my code I have a primary key, do not why - now that code works

    I made no changes, but the code now works.
    Best regards
    Exceter.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center