CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Jan 2003
    Location
    London/Moscow
    Posts
    60

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

  2. #2
    Join Date
    Jan 2003
    Posts
    14
    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.

  3. #3
    Join Date
    Jan 2003
    Posts
    14
    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.

  4. #4
    Join Date
    Jan 2003
    Location
    London/Moscow
    Posts
    60
    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.

  5. #5
    Join Date
    Jan 2003
    Posts
    14
    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?

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured