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

How can I do that?

Hi. I need to map items from a DataSet to a SQL table.
The problem is that in the DataSet I can have the same item repeted, but in
the table, I have a field "quantity" to avoid that. So what I need is a
structure where I get each item and the number of repetitions.

In the DataSet, I have one table and I only need to use one column, and the
items are integers, so the idea is passing from:

100 102 100 103 to
100 (2) 102 (1) 103 (1) or something like that.

I don't know if I can get something with the DataSet Select method. I passed
the column to an ArrayList, but I don't know if that simplifyes something.

Can you help me?

Regards,

Diego F.
Nov 16 '05 #1
2 1095
It would probably be better (easier or more efficient) to have the SQL
Server worry about and handle the repetitions, then all you need is for for
code to move through each value and fire it to the SQL Server (which would
be incredibly fast and easy to implement).

Basically on the SQL Server, you would write a stored procedure that takes
the integer input and checks if it already exists, if so it would increment
the quantity of that row. Otherwise it would insert a brand new row for that
integer.
Your code could then simply call the stored procedure for each integer in
the dataset.

Hope this helps.

Br,

Mark.

"Diego F." <di*******@terra.es> wrote in message
news:O5**************@TK2MSFTNGP09.phx.gbl...
Hi. I need to map items from a DataSet to a SQL table.
The problem is that in the DataSet I can have the same item repeted, but in the table, I have a field "quantity" to avoid that. So what I need is a
structure where I get each item and the number of repetitions.

In the DataSet, I have one table and I only need to use one column, and the items are integers, so the idea is passing from:

100 102 100 103 to
100 (2) 102 (1) 103 (1) or something like that.

I don't know if I can get something with the DataSet Select method. I passed the column to an ArrayList, but I don't know if that simplifyes something.

Can you help me?

Regards,

Diego F.

Nov 16 '05 #2
Diego,

This is like a crosstab somewhat, with some calculated values. The
Select method will not be able to help you, as it doesn't allow for the
selection of distinct items.

What I would do is use a DataView and sort the column. Then, cycle
through all the rows, maintaining a count of each unique value (it would be
easy enough to implement change detection).

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Diego F." <di*******@terra.es> wrote in message
news:O5**************@TK2MSFTNGP09.phx.gbl...
Hi. I need to map items from a DataSet to a SQL table.
The problem is that in the DataSet I can have the same item repeted, but
in
the table, I have a field "quantity" to avoid that. So what I need is a
structure where I get each item and the number of repetitions.

In the DataSet, I have one table and I only need to use one column, and
the
items are integers, so the idea is passing from:

100 102 100 103 to
100 (2) 102 (1) 103 (1) or something like that.

I don't know if I can get something with the DataSet Select method. I
passed
the column to an ArrayList, but I don't know if that simplifyes something.

Can you help me?

Regards,

Diego F.

Nov 16 '05 #3

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

Similar topics

1
by: sentinel | last post by:
Hi, I'm currently writing a mulit-page form app that uses a session to retain data from each form element in order for the user to jump between pages, then the final data is passed to a calculation...
2
by: ChronicFatigue | last post by:
Given that some browsers dont have javascript enabled.... do developers try to avoid using javascript when a php alternative can be used? What sort of alternative php scripts are often used?
1
by: Timothy Rue | last post by:
I found the online and free PHP manual(s) but what I need is one that is plain text/ascii Is there such a beast and if not what is the closest to it? I'd like to do my own markup on it. ...
5
by: Nick Bartos | last post by:
I am looking for an open source php accelerator that works in cgi mode. I am guessing that to do that the cache would have to be on disk and not in memory. I was looking at the turk accelerator...
2
by: Martien van Wanrooij | last post by:
I am rather new at php so the answer to my question could be somewhere on the web but unfortunately I couldn't find it until now. I am using a form that is sent to me by email with the following...
4
by: Randell D. | last post by:
Folks, I use PHP to write my form data to MySQL. I have a database with about ten tables. I'm trying to fill one table with some dummy data (its a contact manager table holding names of...
3
by: simonc | last post by:
I'm getting incoming emails to activate a PHP script, not web page requests - so I can't visibly see things with a browser. Is there any way I can detect if one of my PHP scripts never exits -...
5
by: Beef Erikson | last post by:
Heya :) Ok... I've been thinking of a way to go about doing this, and I think I might have came up with it. Just wanting to run this by you guys, see what you think. Here's my setup: I...
3
by: Stijn Goris | last post by:
hi all, Does a function excist that converts a string to a string thats compatible with linux file system? kind regards Stijn
7
by: Jayne Wolps | last post by:
Hello I wonder if anyone can help. I would like to know how certain sites: http://aboutbritain.com/ArundelCastle.htm, and http://travel.knowhere.co.uk/place/+bristol-0/ manage to put approx...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...

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.