473,789 Members | 2,785 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how can I create a copy of a DataRow that lasts after datatable is cleared?

If I have just filled a DataTable in a typed DataSet with a single
row, is there a way I can make a copy of that row, so that I can clear
the DataTable in that DataSet and use it for another query, but my
copy of the row will be preserved?

If I try to do something like this:

this.oleDbWbuse rAdapter.Select Command.Command Text =
"SELECT * FROM wbuser where username='benne tt';";
this.oleDbWbuse rAdapter.Fill(d s1.wbuser);
dsLocalDataSet. wbuserRow currRow = ds1.wbuser[0];

ds1.Clear();

this.oleDbWbuse rAdapter.Select Command.Command Text =
"SELECT * FROM wbuser where username='benne tt2';";
this.oleDbWbuse rAdapter.Fill(d s1.wbuser);

// this won't work; reference to currRow is no longer valid
Response.Write( currRow.usernam e);

(where dsLocalDataSet is a typed DataSet class containing a table
called "wbuser") then this won't work, because currRow just refers to
row zero of the ds1.wbuser DataTable, and when I call ds1.Clear(),
currRow disappears.

On the other hand DataRow doesn't appear to have a built-in method for
making a copy of itself. The ds1.wbuser DataTable class does have a
member method called NewwbuserRow() generated for it, but it doesn't
take any arguments, so I can't pass an existing wbuser row to it and
make a copy. Is there some way to make a copy that I can refer to
later in the code, even after I've cleared out the dataset object and
reused it for another query? Or do I have to use a different dataset
object for every query, if I want to keep the row objects around so
that I can refer to them later in the code?

-Bennett
Nov 18 '05 #1
0 1242

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

Similar topics

0
2535
by: dudi | last post by:
I am encountering the following strange problem which causes the application to use more memory then it should. I have 5 database tables. lets pretend I want to load each one of them into a dataTable. then, run over all the rows of the dataTable and for each cell in the dataRow concatenate a string (the value in the cell is a string to begin with). I expect the memory to go up every time I load a dataTable, even go up when I modify the...
0
5832
by: Kelvin | last post by:
Hi All, Due to can't insert new row between row and row while current DataTable looping. In order to solve the problem, I need to clone it as new DataTable, while the DataTable Looping, it also insert both of new row and existing datarow into new DataTable, but I don't know how to do that, Here is my souce code, Please advise. if ( myTable.Rows.Count > 0 )
2
3180
by: Fredrik Rodin | last post by:
All, I've been looking around for a solution to my problem for a couple of days now. In short, here's my situation: 1. I'm getting a result from a component back as a datatable and I have no option to sort the different columns during the call to the component.
3
9449
by: ypul | last post by:
can anyone tell me please .. how to copy one datarow from one datatable to another.. I want to extract some specific rows from one datatable and put into antoher .... " datatableOne.rows.add(datatableTwo.rows(i))" this statement does not work ..it says
12
2288
by: Doug Bell | last post by:
Hi, I am having problems trying to create a (temporary) DataTable from a selection from a DataGrid (dgOrders). dtOrdDetails is declared as a Public DataTable Sub is: Dim stFilter as String Dim OrdersRows() as DataRow
2
1732
by: Li Pang | last post by:
Hi, I created a datatable (dt1) of 3 columns A, B, C, and I want to copy this datatable into another datatable (dt2) but without the column B. How to do this? Thanks in advance
1
2431
by: Ryan Liu | last post by:
Hi, Is that safe to say a Detached DataRow neve in a DataTable's Rows collectoin? But in my log file, I do see a Detached row: foreach(DataRow dr in this.currentQuotaUserDt.Rows) {
6
28330
by: Pete Wittig | last post by:
Hi, I have a DataTable and I want to get a subset of the rows within it. I use the Select method to get my subset and the results are in a DataRow. I want to put those Rows back into a DataTable. I've tried a few variations of the following but no rows are every imported into the datatable: DataRow datrow = ds.Tables.Select("PersonID = " + id); DataTable dt = new DataTable();
1
1507
by: SunshineInTheRain | last post by:
Dim dtUn As DataTable dtUn= New DataTable dtUn = BindICUN() Dim i As Integer Dim irow As DataRow Dim mailBody As String = "" Dim myRow As DataRow Dim rowSet As DataRow() rowSet = dtUn.Select("Distinct Member_id is not null")
0
9665
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
9511
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
10408
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
10199
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
10139
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
6768
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4092
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3697
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2909
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.