473,289 Members | 1,923 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,289 software developers and data experts.

How get data using array or hashtable

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
2 1677
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Kevin | last post by:
Hi, I am wondering if I use a hashtable instead of a dataset to hold data in my app will have less overhead and better performance? I am really looking for a data container where I can use a...
5
by: Bob Weiner | last post by:
I'm new to C#. What is the best (in terms of programmability and use) data structure to use to maintain an array of information with containing 3 fields of differing types. For instance:...
8
by: xmail123 | last post by:
Hi, As was pointed out whatever you return from a WebMethod needs to be serializable to SOAP. An ArrayList is not serializable. I will be needing to return other data types from web methods. ...
2
by: mark4asp | last post by:
Hello, I am converting an app from JavaScript to ASP.NET I have the following JavaScript 'associative array'. Is there a concise way to create an analogous structure in .NET Framework using...
11
by: hoopsho | last post by:
Hi Everyone, I am trying to write a program that does a few things very fast and with efficient use of memory... a) I need to parse a space-delimited file that is really large, upwards fo a...
7
by: Leszek Taratuta | last post by:
Hello, I need a kind of lightweight data structure known as "associative array". It will store a few values that I need to access using textual keys. The Hashtable is too heavy for me. I also...
6
by: James | last post by:
I am using vb.net and need to keep in memory a large data structure, so I am looking for the best option. And after several test I am pretty confused. So I will be grateful if anyone can help me. ...
3
by: Mukesh | last post by:
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...
3
by: kevinwolfe | last post by:
Hi all. I'd like any suggestions on how I can get my data set (not a DataSet) bound to a couple of controls on a form. Let me start by describing what my data looks like. Each entry correlates...
13
by: jehugaleahsa | last post by:
Hello: I got tired of trying to find good implementations of collections and other data structures in C#. So, I started implementing my own. However, data structures is a wholly different...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
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: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
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: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...

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.