Results 1 to 2 of 2

Thread: Datatable problem

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Sep 2004
    Location
    The BIG City
    Posts
    27

    Datatable problem

    Hi,

    I'm having a problem trying to check for existence of a column in my datatable.

    In my code i'm trying to check if the column "AmountID" exists in the datatable or not...
    VB Code:
    1. If IsNothing(objDT.Columns("AmountID")) then
    2. .
    3. .
    4. .
    5. End If
    If the column is present then its fine, but in case it does NOT exist then i get some error like this...
    Exception Details: System.ArgumentException: Column 'AmountID' does not belong to table tblUpdateRates.

    Any help will be much appreciated...
    thanks in advance

  2. #2
    PowerPoster 2.0 Negative0's Avatar
    Join Date
    Jun 2000
    Location
    Southeastern MI
    Posts
    4,367

    Re: Datatable problem

    Try the Contains method on the columns

    VB Code:
    1. objDT.Columns.Contains(""AmountID")

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