Results 1 to 2 of 2

Thread: [RESOLVED] I Need TABLENAME & ColumnName From DataReader

  1. #1

    Thread Starter
    Addicted Member SpeedyDog's Avatar
    Join Date
    Feb 2004
    Location
    Missouri, USA
    Posts
    189

    Resolved [RESOLVED] I Need TABLENAME & ColumnName From DataReader

    Ok, I'm using MySQL and a Datareader. I couldn't do the whole
    Variable = dr.GetValue(#) because the Databases are dynamic.
    so I have to create a quick chart in runtime.

    It's like
    ColumName = 0
    ColumnName = 1
    ColumnName = 2

    then I can do dr.GetValue(ColumnName) (and it will put in my #)

    now, the issues comes up on the ColumnName. I can't just use
    Price because, that is in multiple Tables in the join. I need to do
    TableName.Price.

    I've tried both
    DataReader.GetSchemaTable() (Looked through all properties)
    and the DataReader.GetName(#)

    Yeah... they get the Name of the Column, but not The TableName.

    VB Code:
    1. SELECT Body.* FROM Body
    2. LEFT JOIN medispan.* ON body.transaction_id=medispan.transaction_id
    3. LEFT JOIN fdb.* ON body.transaction_id=fdb.transaction_id
    4. WHERE medispan.transaction_id IS NOT NULL;

    ok, so look at this statement, the tables medispan and fdb are almost identical, they are two different pricing sources. so I need a columnname of "fdb.columnname" to be given to me from the DataReader. Is it possible to get the table that the Column comes from?
    Last edited by SpeedyDog; Feb 18th, 2006 at 10:41 PM.

  2. #2

    Thread Starter
    Addicted Member SpeedyDog's Avatar
    Join Date
    Feb 2004
    Location
    Missouri, USA
    Posts
    189

    Fixed Myself

    Ok, I found my own result... It comes down to how you Execute the DataReader.

    dr = comm2.ExecuteReader(CommandBehavior.KeyInfo);


    with this, now when you get the Schema
    schemaTable = dr.GetSchemaTable();

    the: BaseTableName = Fdb

    Now, the only problem is, I got rid of my CommandBehavior.CloseConnection anyone know of away to have both?

    FULL ARTICLE to how I solved the problem:

    http://www.dotnet247.com/247referenc...25/126382.aspx

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