By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,187 Members | 1,629 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,187 IT Pros & Developers. It's quick & easy.

How get data using array or hashtable

P: n/a
Hi
I am creating a web application in which I am using datagrid. In this
application I am creating a shopping cart sort of application, I have
primery keys of selected items in a array i want to take full details
of the them in a single datareader. How can i do this passing a single
hashtable or array in database and retriving the desired data in a
single datatable. plz give me any idea or link
Thx
Mukesh Agarwal
May 16 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
You can't pass an array or hashtable into a database.

You can however, pass a 0:N item list thru xml to the database.

Check my article:
http://www.sqlservercentral.com/columnists/sholliday/
"Zero to N"

You can keep your values in a Array or Hashtable....

Right before you want to query the database, convert it to a strongly typed
dataset, and push the DataSet.GetXml() into the stored procedure.

The xml of a StronglyType dataset would look something like this.
<ProductsListDS>
<Product>
<ProductID>123</ProductID>
</Product>
<Product>
<ProductID>567</ProductID>
</Product>
<Product>
<ProductID>897</ProductID>
</Product>
</ProductsListDS>


"Mukesh" <ef*****@newsgroups.nospam> wrote in message
news:uG*************@TK2MSFTNGP02.phx.gbl...
Hi
I am creating a web application in which I am using datagrid. In this
application I am creating a shopping cart sort of application, I have
primery keys of selected items in a array i want to take full details
of the them in a single datareader. How can i do this passing a single
hashtable or array in database and retriving the desired data in a
single datatable. plz give me any idea or link
Thx
Mukesh Agarwal

May 16 '06 #2

P: n/a
Not sure of your question.

Are you looking to fetch multiple records from a database, using a list
of "selected product IDs" ?

All you need is a simple Select query

"SELECT A, B, C FROM [MYPRODUCTTABLE] WHERE MYPRODUCTKEY IN(
PRODUCTKEY1, PRODUCTKEY 2, ... )"

Construct the query by looping through your selected products
array/hashtable (using a for-each)

WARNING: make sure you protect agains SQL injection attacks.

g'luck.
-- a --

Mukesh wrote:
Hi
I am creating a web application in which I am using datagrid. In this
application I am creating a shopping cart sort of application, I have
primery keys of selected items in a array i want to take full details
of the them in a single datareader. How can i do this passing a single
hashtable or array in database and retriving the desired data in a
single datatable. plz give me any idea or link
Thx
Mukesh Agarwal


Jun 8 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.