Click to See Complete Forum and Search --> : Input string was not in a correct format. mscorlib


Exceter
July 13th, 2004, 11:27 PM
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)

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

alexey_1979
July 14th, 2004, 12:55 AM
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
table.Rows.Find(10)

Exceter
July 14th, 2004, 01:18 AM
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
:thumb:
I made no changes, but the code now works.