473,398 Members | 2,427 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,398 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
3 2221
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
Hi Mukesh,

Yes, I agree with sloan that it's not a good idea to put data in a
DataTable into an array or hashtable. Because only the data in a DataTable
or a DataSet can be updated to database using DataAdapter, which is the
simplest way of updating data. If you need to save data temporarily, please
use GetXml or WriteXml method.

Kevin Yu
Microsoft Online Community Support

================================================== ==========================
==========================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
================================================== ==========================
==========================

(This posting is provided "AS IS", with no warranties, and confers no
rights.)

May 17 '06 #3
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 #4

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. ...
2
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.