473,322 Members | 1,287 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

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

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

Nov 19 '05 #1
2 1160
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
el********@hotmail.com


"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

Nov 19 '05 #2
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
el********@hotmail.com


"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

Nov 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: MJL | last post by:
This is a mysql/php question (but a little more on the mysql side.) The two are so closely related these days, I thought it would be ok to ask here. I installed on my Suse Linux system mysql 4.0...
5
by: Rob Wire | last post by:
For the code below, how could I add an item in the drop down lists for both company and location to be an "All" selection that would send to the stored proc. spRptAttachments a value of "%" so...
7
by: Bart Schelkens | last post by:
Hi, I have 2 more questions : 1. Can I fill a datagrid by using a DataReader or does it have to be a DataSet or a DataView? 2. In my datagrid I need to display two images and one of does...
20
by: Mark | last post by:
Hi all, quick question , a DataView is memory resident "view" of data in a data table therefore once populated you can close the connection to the database. Garbage collection can then be used to...
1
by: Jim via DotNetMonster.com | last post by:
Hi, I'm trying to set one of the columns in the datareader to a variable so that I can use it in a different function. When I do that then all the other values in the data reader don't show up....
23
by: Russ Chinoy | last post by:
Hi, This may be a totally newbie question, but I'm stumped. If I have a function such as: function DoSomething(strVarName) { ..... }
10
by: Tony K | last post by:
How would I assign the result of a SQL query to a variable. The result of the following statement will ALWAYS result in 1 row returned. SELECT ProductDescription, ProductID FROM ...
2
by: bcshaw | last post by:
Hey all I have a vb.net/asp.net dynamic website connected to an access database using a oledb connection. I use a datareader to retrieve the results of a query and iterate through the results using...
6
by: Mo Bandy | last post by:
Using FSO I want to copy a file from the web server to a mapped network drive (Novell server) using a physical path. However I keep getting an error (path not found). Can someone help...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.