Variable and DataReader Question. Help Please. I looked everywhere. Thanks.

Discussion in 'ASP .Net' started by Shapper, Apr 22, 2005.

  1. Shapper

    Shapper Guest

    Hello,

    I have a DataReader which returns only one record from a database:

    ID Name Content
    12 hello world

    Is it possible to create a variable named var_hello which value is
    "world"?

    It would be creating something like this:

    var_[Name(ID)]=Content(ID) ,where ID=12.

    I looked everywhere how to do this but I can't find a way.

    Thank You,
    Miguel
    Shapper, Apr 22, 2005
    #1
    1. Advertising

  2. RE: Variable and DataReader Question. Help Please. I looked everywhere

    Hi Shapper,

    You can use HashTable to store Key/Value pair in collection:

    HashTable HtContent = new HashTable();
    while (datareader.Read())
    {
    HtContent .Add(datareader["ID"], datareader["Content"]);
    }

    // then you can get Content by

    string strContent = HtContent .Item[ID];

    HTH

    Elton Wang





    "Shapper" wrote:

    > Hello,
    >
    > I have a DataReader which returns only one record from a database:
    >
    > ID Name Content
    > 12 hello world
    >
    > Is it possible to create a variable named var_hello which value is
    > "world"?
    >
    > It would be creating something like this:
    >
    > var_[Name(ID)]=Content(ID) ,where ID=12.
    >
    > I looked everywhere how to do this but I can't find a way.
    >
    > Thank You,
    > Miguel
    >
    >
    =?Utf-8?B?RWx0b24gVw==?=, Apr 23, 2005
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Andy Sutorius

    In Classic ASP it looked like...

    Andy Sutorius, Jun 24, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    2,220
    Andy Sutorius
    Jun 30, 2004
  2. Shapper
    Replies:
    9
    Views:
    417
    Sean M
    Jun 17, 2005
  3. provato
    Replies:
    2
    Views:
    495
    provato
    Jul 15, 2005
  4. Stephan Kämper
    Replies:
    2
    Views:
    227
    Stephan Kämper
    Jan 18, 2004
  5. Zachary Buckholz
    Replies:
    11
    Views:
    140
    G Klinedinst
    Jan 17, 2004
Loading...

Share This Page