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

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.DataSet
Dim MySPcommand As New System.Data.SqlClient.SqlCommand
MySPcommand.CommandText = "SP4105201getWebFeeTable"
MySPcommand.CommandType = Data.CommandType.StoredProcedure
MySPcommand.Connection =
GlobalLeague.Utilities.Functions.GetConnection(Tru e)
MySPcommand.Parameters.AddWithValue("@ProjectNo",
const_WarsawProjectNo)
Me.FeesDataSet.Tables.Add("Fees")
Me.FeesDataSet.Tables(0).Load(MySPcommand.ExecuteR eader())
MySPcommand.Connection.Close()
MySPcommand = Nothing

So far, so good. We then need to add a couple of "discretionary 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.Tables("Fees").Select("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 4257
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*******@yahoo.comschreef in bericht
news:11*********************@m79g2000cwm.googlegro ups.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.DataSet
Dim MySPcommand As New System.Data.SqlClient.SqlCommand
MySPcommand.CommandText = "SP4105201getWebFeeTable"
MySPcommand.CommandType = Data.CommandType.StoredProcedure
MySPcommand.Connection =
GlobalLeague.Utilities.Functions.GetConnection(Tru e)
MySPcommand.Parameters.AddWithValue("@ProjectNo",
const_WarsawProjectNo)
Me.FeesDataSet.Tables.Add("Fees")
Me.FeesDataSet.Tables(0).Load(MySPcommand.ExecuteR eader())
MySPcommand.Connection.Close()
MySPcommand = Nothing

So far, so good. We then need to add a couple of "discretionary 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.Tables("Fees").Select("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.TableName = "Charges"
For Each ChargesRow In FeesDataSet.Tables("Fees").Select("Pick
= 1")
ChargesTable.ImportRow(ChargesRow)
Next
If Not Me.FeesDataSet.Tables("Charges") Is Nothing Then
Me.FeesDataSet.Tables.Remove("Charges")
End If
Me.FeesDataSet.Tables.Add(ChargesTable)

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*******@yahoo.comschreef in bericht
news:11*********************@m79g2000cwm.googlegro ups.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.DataSet
Dim MySPcommand As New System.Data.SqlClient.SqlCommand
MySPcommand.CommandText = "SP4105201getWebFeeTable"
MySPcommand.CommandType = Data.CommandType.StoredProcedure
MySPcommand.Connection =
GlobalLeague.Utilities.Functions.GetConnection(Tru e)
MySPcommand.Parameters.AddWithValue("@ProjectNo",
const_WarsawProjectNo)
Me.FeesDataSet.Tables.Add("Fees")
Me.FeesDataSet.Tables(0).Load(MySPcommand.ExecuteR eader())
MySPcommand.Connection.Close()
MySPcommand = Nothing

So far, so good. We then need to add a couple of "discretionary 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.Tables("Fees").Select("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
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...
13
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...
17
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). ...
5
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...
4
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...
3
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...
5
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...
9
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...
0
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...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
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: 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...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.