-
searching datatable
Hi all,
I'm trying to search a datatable and not sure how to do it. The table has 2 elements with ID set to be a Primary key and URL set to be a normal Key.
I need to search the table with the key value. but when i try the find method just quits/fails without generating any error. could someone tell me what is happening (what type of error is it) and how can i locate the desired URL.
Code:
Dim FileName(1) As String
FileName(0) = ""
FileName(0) = strPath(i)
Dim PresentFile As DataRow = ds.Tables("Files").Rows.Find(FileName)
The
Code:
<xs:element name="Files">
<xs:complexType>
<xs:sequence>
<xs:element name="ID" msdata:AutoIncrement="true" msdata:AutoIncrementSeed="1" msdata:Caption="File UID" type="xs:int" />
<xs:element name="URL" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
-
did u fill the dataset with the schema before filling it with the data?
nameOfDataAdapter.fillschema(dataset1, SchemaType.Source)
try that if you haven't got it.
-
actually i think you will only be able to use the find thing on the primary key. Not sure if this is what u are trying to do or not.
-
yes i've read the schema.
i need to be able to determine whether the certain file (c:\myfile.htm) is already in a table.
i can do it using for loop on a table.rows object. just was wondering whether there is (there must be) a better way of determining its presence.
-
not sure then.
I know you can find a row in a dataset by the tables primary key, but not sure about any other.
You could just put a where clause in an SQL statement and querry the table again?