473,659 Members | 2,965 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Transferring data between datatables and between datareader and datatable

Can anyone help with some problkems that have wasted 2 days of my
(inexperienced) time already?

We have a website which allows people to register for events like
conferences

We are importing a table of fees for the apporpriate event using an Sp:
FeesDataSet = New System.Data.Dat aSet
Dim MySPcommand As New System.Data.Sql Client.SqlComma nd
MySPcommand.Com mandText = "SP4105201getWe bFeeTable"
MySPcommand.Com mandType = Data.CommandTyp e.StoredProcedu re
MySPcommand.Con nection =
GlobalLeague.Ut ilities.Functio ns.GetConnectio n(True)
MySPcommand.Par ameters.AddWith Value("@Project No",
const_WarsawPro jectNo)
Me.FeesDataSet. Tables.Add("Fee s")
Me.FeesDataSet. Tables(0).Load( MySPcommand.Exe cuteReader())
MySPcommand.Con nection.Close()
MySPcommand = Nothing

So far, so good. We then need to add a couple of "discretion ary fees"
if the customer selects the approriate boxes on the page. We get a
single row of data (same format but different SP) and ideally need to
add that row to the "Fees" table. I can get it into another table (same
method as above) or into a datareader, but cannot find exactly how to
add it as a row into the "Fees" table from either the new table or from
a datareader?

A little later, we use the controls on the web page to pick up the
customer's options and I am storing these by changing the (existing)
"Pick" field in the "Fees" table to 1 for the appropriate rows (ie
fees). I can then get use:
FeesDataSet.Tab les("Fees").Sel ect("Pick = 1")
to get a set of rows which we need to charge to this customer. Ideally
I want to move these to another table ("Charges") in the same dataset,
so that we can perform various calculations and text changes on them
before printing them to his invoice. I have tried cloning the table to
set the schema for the "Charges" table to match the "Fees" table and
then import the rows, but I cannot seem to get the code right.

Can anyone help me with these 2 tasks - ie getting a row from a table
or datareader and copying it into the "Fees" table, asnd then taking a
set of selected rows from the "Fees" table and using them to create the
"Charges" table?

Jul 4 '06 #1
2 4279
Neil,

That was very much reading and trying to understand.

Probably are you just looking for the command importrow

http://msdn2.microsoft.com/en-us/lib...importrow.aspx

You cannot add a datarow to two tables, simple for the fact that the datarow
has a property which tells to what datatable it belongs

I hope this helps,

Cor

"neilr" <ne*******@yaho o.comschreef in bericht
news:11******** *************@m 79g2000cwm.goog legroups.com...
Can anyone help with some problkems that have wasted 2 days of my
(inexperienced) time already?

We have a website which allows people to register for events like
conferences

We are importing a table of fees for the apporpriate event using an Sp:
FeesDataSet = New System.Data.Dat aSet
Dim MySPcommand As New System.Data.Sql Client.SqlComma nd
MySPcommand.Com mandText = "SP4105201getWe bFeeTable"
MySPcommand.Com mandType = Data.CommandTyp e.StoredProcedu re
MySPcommand.Con nection =
GlobalLeague.Ut ilities.Functio ns.GetConnectio n(True)
MySPcommand.Par ameters.AddWith Value("@Project No",
const_WarsawPro jectNo)
Me.FeesDataSet. Tables.Add("Fee s")
Me.FeesDataSet. Tables(0).Load( MySPcommand.Exe cuteReader())
MySPcommand.Con nection.Close()
MySPcommand = Nothing

So far, so good. We then need to add a couple of "discretion ary fees"
if the customer selects the approriate boxes on the page. We get a
single row of data (same format but different SP) and ideally need to
add that row to the "Fees" table. I can get it into another table (same
method as above) or into a datareader, but cannot find exactly how to
add it as a row into the "Fees" table from either the new table or from
a datareader?

A little later, we use the controls on the web page to pick up the
customer's options and I am storing these by changing the (existing)
"Pick" field in the "Fees" table to 1 for the appropriate rows (ie
fees). I can then get use:
FeesDataSet.Tab les("Fees").Sel ect("Pick = 1")
to get a set of rows which we need to charge to this customer. Ideally
I want to move these to another table ("Charges") in the same dataset,
so that we can perform various calculations and text changes on them
before printing them to his invoice. I have tried cloning the table to
set the schema for the "Charges" table to match the "Fees" table and
then import the rows, but I cannot seem to get the code right.

Can anyone help me with these 2 tasks - ie getting a row from a table
or datareader and copying it into the "Fees" table, asnd then taking a
set of selected rows from the "Fees" table and using them to create the
"Charges" table?

Jul 4 '06 #2

Cor,
That got me started, thank you - I had tried that before but must have
got the code wrong. It now works, as follows if anyone else needs help:
Dim ChargesTable As Data.DataTable
ChargesTable = Me.FeesDataSet. Tables("Fees"). Clone
ChargesTable.Ta bleName = "Charges"
For Each ChargesRow In FeesDataSet.Tab les("Fees").Sel ect("Pick
= 1")
ChargesTable.Im portRow(Charges Row)
Next
If Not Me.FeesDataSet. Tables("Charges ") Is Nothing Then
Me.FeesDataSet. Tables.Remove(" Charges")
End If
Me.FeesDataSet. Tables.Add(Char gesTable)

By the way, my note was long because I had read so many where novices
like me were criticised for not including their code and explaining the
problem!

Thanks again, Neil

Cor Ligthert [MVP] wrote:
Neil,

That was very much reading and trying to understand.

Probably are you just looking for the command importrow

http://msdn2.microsoft.com/en-us/lib...importrow.aspx

You cannot add a datarow to two tables, simple for the fact that the datarow
has a property which tells to what datatable it belongs

I hope this helps,

Cor

"neilr" <ne*******@yaho o.comschreef in bericht
news:11******** *************@m 79g2000cwm.goog legroups.com...
Can anyone help with some problkems that have wasted 2 days of my
(inexperienced) time already?

We have a website which allows people to register for events like
conferences

We are importing a table of fees for the apporpriate event using an Sp:
FeesDataSet = New System.Data.Dat aSet
Dim MySPcommand As New System.Data.Sql Client.SqlComma nd
MySPcommand.Com mandText = "SP4105201getWe bFeeTable"
MySPcommand.Com mandType = Data.CommandTyp e.StoredProcedu re
MySPcommand.Con nection =
GlobalLeague.Ut ilities.Functio ns.GetConnectio n(True)
MySPcommand.Par ameters.AddWith Value("@Project No",
const_WarsawPro jectNo)
Me.FeesDataSet. Tables.Add("Fee s")
Me.FeesDataSet. Tables(0).Load( MySPcommand.Exe cuteReader())
MySPcommand.Con nection.Close()
MySPcommand = Nothing

So far, so good. We then need to add a couple of "discretion ary fees"
if the customer selects the approriate boxes on the page. We get a
single row of data (same format but different SP) and ideally need to
add that row to the "Fees" table. I can get it into another table (same
method as above) or into a datareader, but cannot find exactly how to
add it as a row into the "Fees" table from either the new table or from
a datareader?

A little later, we use the controls on the web page to pick up the
customer's options and I am storing these by changing the (existing)
"Pick" field in the "Fees" table to 1 for the appropriate rows (ie
fees). I can then get use:
FeesDataSet.Tab les("Fees").Sel ect("Pick = 1")
to get a set of rows which we need to charge to this customer. Ideally
I want to move these to another table ("Charges") in the same dataset,
so that we can perform various calculations and text changes on them
before printing them to his invoice. I have tried cloning the table to
set the schema for the "Charges" table to match the "Fees" table and
then import the rows, but I cannot seem to get the code right.

Can anyone help me with these 2 tasks - ie getting a row from a table
or datareader and copying it into the "Fees" table, asnd then taking a
set of selected rows from the "Fees" table and using them to create the
"Charges" table?
Jul 4 '06 #3

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

Similar topics

0
3417
by: nima | last post by:
Hi I have two tables in my database. PRODUCT and PRODUCT_GROUP. PRODUCT has a foreign key to PRODUCT_GROUP. I generated a typed dataset using VS.net and added a relationship between the two tables. When I call my get WebMethod for the PRODUCT table I get the System.Data.ConstraintException exception. The get WebMethod for PRODUCT_GROUP works fine. When I remove the relationship the get WebMethod for PRODUCT works fine too. Both tables...
13
5241
by: Leszek Taratuta | last post by:
Hello, I have several drop-down lists on my ASP.NET page. I need to keep data sources of these lists in Session State. What would be the most effective method to serialize this kind of data structures? Thanks for any hints, Leszek Taratuta
17
3012
by: Justin Emlay | last post by:
I'm hopping someone can help me out on a payroll project I need to implement. To start we are dealing with payroll periods. So we are dealing with an exact 10 days (Monday - Friday, 2 weeks). I have a dataset as follows (1 week to keep it short): Employee 1 - Date 1 Employee 1 - Date 2
5
2493
by: atif | last post by:
Hi all I have read 5-6 books just to find what is the job of Adaptor object in ADO.NET. Non of them clearly defines the job, all of them says that it is used to get data from datasource, then what is the job of Command object?? Here is what i know, very simple and prime responsibilities Connection = Link with Data Source
4
2472
by: JIM.H. | last post by:
Hello, I am trying to write the data I got from a web service to my table in SQL Server I need to append the dataset wsDS to the dataset ds and do update. PVS.myWS.Loader load = new PVS.myWS.Loader(); DataSet wsDS=load.WsLoad(); dataGrid1.DataSource=wsDS; string strConn = ConfigurationSettings.AppSettings;
3
1265
by: Ben R. | last post by:
Since the original thread is marked as answered, I thought I'd post here to ensure visibility. Hi John and Steven, I'm going the dataset route as access doesn't seem to be too keen on that level of complexity in joins. Anyway, I'm curious as to why it makes more sense to fill a datatable and then contsruct a new datatable from the first one. Why not just create a datatable based off of a datareader? To be honest, I'm not too familiar...
5
6436
by: sutphinwb | last post by:
Hi - This could be a simple question. When I relate two tables in a datasetet, how do I get that relation to show up in a GridView? The only way I've done it, is to create a separate table in the dataset with a join query for the GetData() select method. I use ObjectDataStore to couple the GridView with the table adapter on the dataset. If I point the ODS at the child table, the GridView will bind to the "normal" select and I end up...
9
4012
by: Anil Gupte | last post by:
After reading a tutorial and fiddling, I finally got this to work. I can now put two tables created with a DataTable class into a DataRelation. Phew! And it works! Dim tblSliceInfo As New DataTable("SliceInfo") Dim tblSliceRatings As New DataTable("SliceRatings") '.... All the adding datacolumns, datarows, etc. goes here.. DatasetInit.Tables.Add(tblSliceInfo)
0
4547
by: mike1402 | last post by:
Hi ! I get the error below sometimes when retrieving a big amount of data using Datadapter.Fill(dataset,"table"). But when I send the command Fill again, there is no error. Is it a fault of IBM.Data.DB2.iSeries; Version: v1.0.3705 (is there an newer one for OS/400 Version ist V5R3 ?) or is it a hardware faoult (memory of as400 or pc) ? br mike Es wurde versucht, im geschützten Speicher zu lesen oder zu schreiben. Dies ist häufig ein...
0
8428
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8335
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8851
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8747
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8528
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7356
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4175
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
1976
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1737
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.