473,770 Members | 4,544 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

DataView loop and edit?

Dear friends

Dim myDataView as DataView = New DataView(dsData .Tables("tblCus tomers"))

myDataView.RowF ilter = "City = 'London'"

My question is how to loop through all rows in myDataView and edit the field
fldZipCode so fldZipCode = "9800"

Regards Able
Nov 20 '05
14 9878
Has to define my question more accurately:

Dim myDataView as DataView = New DataView(dsData .Tables("tblCus tomers"))

This works:
myDataView.RowF ilter = "City = 'London'"

For i as Integer = 0 to myDataView.coun t - 1
myDataView(i)(" fldZipCode")="9 800"
Next

....but this doesnt:
myDataView.RowF ilter = "City = 'London' And fldZipCode = '9000'"

For i as Integer = 0 to myDataView.coun t - 1
myDataView(i)(" fldZipCode")="9 800"
Next

Able
"Able" <ab**@epost.n o> skrev i melding
news:u5******** ***********@new s4.e.nsc.no...
Dear friends

Dim myDataView as DataView = New DataView(dsData .Tables("tblCus tomers"))

myDataView.RowF ilter = "City = 'London'"

My question is how to loop through all rows in myDataView and edit the field fldZipCode so fldZipCode = "9800"

Regards Able

Nov 20 '05 #11
Able,
myDataView.RowF ilter = "City = 'London' And fldZipCode = '9000'"
myDataView(i)(" fldZipCode")="9 800"
Because you used fldZipCode in your Filter, As you change the fldZipCode
field the contents of the collection (the items in the DataView) changes.

The easiest way maybe to use DataTable.Selec t in this case. As
DataTable.Selec t returns a fixed array of rows, where as the DataView is a
dynamic collection of rows.

Something like:
Dim table As DataTable = dsData.Tables(" tblCustomers")
Dim filterExpressio n As String = "City = 'London' And fldZipCode =
'9000'"
For Each row As DataRow in table.Select(fi lterExpression)
row("fldZipCode ")="9800"
Next

Hope this helps
Jay

"Able" <ab**@epost.n o> wrote in message
news:G0******** ***********@new s4.e.nsc.no... Has to define my question more accurately:

Dim myDataView as DataView = New DataView(dsData .Tables("tblCus tomers"))

This works:
myDataView.RowF ilter = "City = 'London'"

For i as Integer = 0 to myDataView.coun t - 1
myDataView(i)(" fldZipCode")="9 800"
Next

...but this doesnt:
myDataView.RowF ilter = "City = 'London' And fldZipCode = '9000'"

For i as Integer = 0 to myDataView.coun t - 1
myDataView(i)(" fldZipCode")="9 800"
Next

Able
"Able" <ab**@epost.n o> skrev i melding
news:u5******** ***********@new s4.e.nsc.no...
Dear friends

Dim myDataView as DataView = New DataView(dsData .Tables("tblCus tomers"))

myDataView.RowF ilter = "City = 'London'"

My question is how to loop through all rows in myDataView and edit the

field
fldZipCode so fldZipCode = "9800"

Regards Able


Nov 20 '05 #12
In addition to Jay

with a dataview

For i As Integer = dv.Count - 1 to 0 step -1
dv(i)("fldZipCo de") = "9800"
Next

Cor
Nov 20 '05 #13
Got it. Thanks a lot.

Regards Able
"Jay B. Harlow [MVP - Outlook]" <Ja************ @msn.com> skrev i melding
news:O$******** ******@tk2msftn gp13.phx.gbl...
Able,
myDataView.RowF ilter = "City = 'London' And fldZipCode = '9000'"
myDataView(i)(" fldZipCode")="9 800"


Because you used fldZipCode in your Filter, As you change the fldZipCode
field the contents of the collection (the items in the DataView) changes.

The easiest way maybe to use DataTable.Selec t in this case. As
DataTable.Selec t returns a fixed array of rows, where as the DataView is a
dynamic collection of rows.

Something like:
Dim table As DataTable = dsData.Tables(" tblCustomers")
Dim filterExpressio n As String = "City = 'London' And fldZipCode =
'9000'"
For Each row As DataRow in table.Select(fi lterExpression)
row("fldZipCode ")="9800"
Next

Hope this helps
Jay

"Able" <ab**@epost.n o> wrote in message
news:G0******** ***********@new s4.e.nsc.no...
Has to define my question more accurately:

Dim myDataView as DataView = New DataView(dsData .Tables("tblCus tomers"))

This works:
myDataView.RowF ilter = "City = 'London'"

For i as Integer = 0 to myDataView.coun t - 1
myDataView(i)(" fldZipCode")="9 800"
Next

...but this doesnt:
myDataView.RowF ilter = "City = 'London' And fldZipCode = '9000'"

For i as Integer = 0 to myDataView.coun t - 1
myDataView(i)(" fldZipCode")="9 800"
Next

Able
"Able" <ab**@epost.n o> skrev i melding
news:u5******** ***********@new s4.e.nsc.no...
Dear friends

Dim myDataView as DataView = New DataView(dsData .Tables("tblCus tomers"))
myDataView.RowF ilter = "City = 'London'"

My question is how to loop through all rows in myDataView and edit the

field
fldZipCode so fldZipCode = "9800"

Regards Able



Nov 20 '05 #14
Cor,
I was actually thinking of sorting the DataView descending, then only
changing element zero, when I did my initial post.

However now that you got me to actually think of the alternatives, you
wouldn't need the sort at all! :-)

myDataView.RowF ilter = "City = 'London' And fldZipCode = '9000'"

Do Until myDataView.Coun t = 0
myDataView(0)(" fldZipCode")="9 800"
Loop

I'm sure there are a couple of other methods...

Jay

"Cor Ligthert" <no**********@p lanet.nl> wrote in message
news:OO******** ******@TK2MSFTN GP11.phx.gbl...
In addition to Jay

with a dataview

For i As Integer = dv.Count - 1 to 0 step -1
dv(i)("fldZipCo de") = "9800"
Next

Cor

Nov 20 '05 #15

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

Similar topics

0
1225
by: wackyphill | last post by:
I loop thru a Filtered DataView and update several of the rows in the loop. The problem is once a ropw gets altered the DataView's Count Seems to be altered causing me to access rows that it doesn't think exist: DataView runView = new DataView( _db.DS.Tables, where, null, DataViewRowState.CurrentRows); foreach( DataRowView row in runView ) {
2
3310
by: Alpha | last post by:
I have a window application. In one of the form, a datagrid has a dataview as its datasource. Initial filtering result would give the datavew 3 items. When I double click on the datagrid to edit the selected lie item at which case I would pop up a separate dialog box to do so, in the debugging code, the dataview.count would return 0. I get a error message because I tried to get values out of a dataview that holds 0 items. Does anyone...
0
741
by: grolms | last post by:
I must recreated dataview . I am in the designer insert dataview set datasource ... And I set before DataBind datasource on the dataview ... How I recreated dataview. I have dataview in class member ... thanx >-----Original Message-----
0
1158
by: Michał Januszczyk | last post by:
Is it possible somehow to retreive {data Key Value} based on clicked {datagrid item index} ? Now i'm trying to do this in the following way, but with no effect. Now, Instead of getting value according to specified sort key i get wrong data HandleInnerDGRControlItemClick(Object sender, DataGridCommandEventArgs args) { int clickedIndex = args.Item.ItemIndex;
8
3899
by: Dave Hagerich | last post by:
I'm using a DataGrid with a DataSet and I'm trying to filter the data being displayed, using the following code as a test: DataView theView = new DataView(theDataSet.Tables); theView.RowFilter = "'Record ID' = '0'"; theView.RowStateFilter = DataViewRowState.ModifiedCurrent; Debug.WriteLine(string.Format("RowFilter = {0}", theView.RowFilter)); RecordDataGrid.DataSource = theView; RecordDataGrid.DataBind();
1
3650
by: Able | last post by:
Dear friends Two of the columns in the table tblAdressbook is the field "FirstName" and the field "personID". The table is loaded in the dataset myDataset and is sorted by "personID" in the dataview myDataView as this: Dim myDataView As DataView = New DataView(myDataset.Tables("tblAdressbokk"), "", _ "personID", DataViewRowState.CurrentRows)
0
1841
by: Nathan Franklin | last post by:
Hello Guys, I have been trying to work this our for so long, but I just can't seem to find the answer. I am loading a datatable from a an access database using an oledbdataadapter. I then assign the datatable.dataview to my datagrid.datasource member so it will display my results.. I need to give the user an option to change the order of this data, I have a
10
1956
by: Marc R. | last post by:
Hi all, I edit records using a form that have multiple control bind on Dataview, But I don't want to update right always to database, I would like to delay until all Changes (add all new record using a form or edit various existing records) This way I could minimize transaction on server..
3
5394
by: =?Utf-8?B?cG1jZ3VpcmU=?= | last post by:
I have a dataset with 3 tables -- 2 Parent tables and 1 table that is a child table of both the parents. I create a dataview on the child table and set the rowfilter to a value which filters the child based on values in both parent tables. When I edit the parent tables the edit is not reflected in the dataview.count property. How can I force the dataview to refresh following parent table edits? For example: Parent1
0
9591
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
9425
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
10228
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...
1
10002
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
9869
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6676
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();...
0
5449
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3970
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
3575
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.