Click to See Complete Forum and Search --> : searching datatable


bratuha
January 22nd, 2003, 07:05 AM
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.


Dim FileName(1) As String
FileName(0) = ""
FileName(0) = strPath(i)
Dim PresentFile As DataRow = ds.Tables("Files").Rows.Find(FileName)


The

<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>

nswan
January 22nd, 2003, 07:21 AM
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.

nswan
January 22nd, 2003, 07:25 AM
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.

bratuha
January 22nd, 2003, 08:49 AM
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.

nswan
January 22nd, 2003, 08:57 AM
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?