473,761 Members | 9,284 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 #1
14 9877
Hi Able,

You can loop though any dataview in the normal way
Typed in this message watch errors
\\\
For i as Integer = 0 to myDataView.coun t - 1
myDataView(i)(" fldZipCode")="9 800"
Next
///
That is all

I hope this helps?

Cor
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 #2
This goes fine
For i as Integer = 0 to myDataView.coun t - 1
MsgBox(myDataVi ew(i)("fldZipCo de"))
Next

but this causes out of range error
For i as Integer = 0 to myDataView.coun t - 1
myDataView(i)(" fldZipCode")="9 800"
Next

Regards Able
"Cor Ligthert" <no**********@p lanet.nl> skrev i melding
news:us******** ******@TK2MSFTN GP11.phx.gbl...
Hi Able,

You can loop though any dataview in the normal way
Typed in this message watch errors
\\\
For i as Integer = 0 to myDataView.coun t - 1
myDataView(i)(" fldZipCode")="9 800"
Next
///
That is all

I hope this helps?

Cor
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 #3
Hi,

This example uses a dataview dv.

Dim drv As DataRowView

For Each drv In dv
drv.BeginEdit()
drv.Item("Posta lCode") = "2345"
drv.EndEdit()
Next

Ken
------------------

"Able" <ab**@epost.n o> wrote in message
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


--
Outgoing mail is certified Virus Free.
Checked by AVG Anti-Virus (http://www.grisoft.com).
Version: 7.0.230 / Virus Database: 263.0.0 - Release Date: 6/2/2004
Nov 20 '05 #4
My DataView has 3 rows and error occurs on editing second row.

Regards Able

"Ken Tucker [MVP]" <vb***@bellsout h.net> skrev i melding
news:uC******** ******@tk2msftn gp13.phx.gbl...
Hi,

This example uses a dataview dv.

Dim drv As DataRowView

For Each drv In dv
drv.BeginEdit()
drv.Item("Posta lCode") = "2345"
drv.EndEdit()
Next

Ken
------------------

"Able" <ab**@epost.n o> wrote in message
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


--
Outgoing mail is certified Virus Free.
Checked by AVG Anti-Virus (http://www.grisoft.com).
Version: 7.0.230 / Virus Database: 263.0.0 - Release Date: 6/2/2004

Nov 20 '05 #5
What's the data in the PostalCode field of the second row?? Is it Null??
_______________ _____________
The Grim Reaper

"Able" <ab**@epost.n o> wrote in message
news:_K******** ***********@new s2.e.nsc.no...
My DataView has 3 rows and error occurs on editing second row.

Regards Able

"Ken Tucker [MVP]" <vb***@bellsout h.net> skrev i melding
news:uC******** ******@tk2msftn gp13.phx.gbl...
Hi,

This example uses a dataview dv.

Dim drv As DataRowView

For Each drv In dv
drv.BeginEdit()
drv.Item("Posta lCode") = "2345"
drv.EndEdit()
Next

Ken
------------------

"Able" <ab**@epost.n o> wrote in message
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


--
Outgoing mail is certified Virus Free.
Checked by AVG Anti-Virus (http://www.grisoft.com).
Version: 7.0.230 / Virus Database: 263.0.0 - Release Date: 6/2/2004


Nov 20 '05 #6
No

"The Grim Reaper" <gr*********@bt openworld.com> skrev i melding
news:c9******** **@sparta.btint ernet.com...
What's the data in the PostalCode field of the second row?? Is it Null??
_______________ _____________
The Grim Reaper

"Able" <ab**@epost.n o> wrote in message
news:_K******** ***********@new s2.e.nsc.no...
My DataView has 3 rows and error occurs on editing second row.

Regards Able

"Ken Tucker [MVP]" <vb***@bellsout h.net> skrev i melding
news:uC******** ******@tk2msftn gp13.phx.gbl...
Hi,

This example uses a dataview dv.

Dim drv As DataRowView

For Each drv In dv
drv.BeginEdit()
drv.Item("Posta lCode") = "2345"
drv.EndEdit()
Next

Ken
------------------

"Able" <ab**@epost.n o> wrote in message
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
>

--
Outgoing mail is certified Virus Free.
Checked by AVG Anti-Virus (http://www.grisoft.com).
Version: 7.0.230 / Virus Database: 263.0.0 - Release Date: 6/2/2004



Nov 20 '05 #7
Hi,

Try this. What is the exact error message printed in the output
window.

Dim drv As DataRowView

For Each drv In dv
Try
drv.BeginEdit()
drv.Item("Posta lCode") = "2345"
drv.EndEdit()
Catch ex As Exception
Trace.WriteLine (ex.ToString)
End Try
Next

Ken
---------------

"Able" <ab**@epost.n o> wrote in message
news:_K******** ***********@new s2.e.nsc.no:
My DataView has 3 rows and error occurs on editing second row.

Regards Able

"Ken Tucker [MVP]" <HYPERLINK
"mailto:vb***@b ellsouth.net"vb ***@bellsouth.n et> skrev i melding
news:uC******** ******@tk2msftn gp13.phx.gbl...
Hi,

This example uses a dataview dv.

Dim drv As DataRowView

For Each drv In dv
drv.BeginEdit()
drv.Item("Posta lCode") = "2345"
drv.EndEdit()
Next

Ken
------------------

"Able" <HYPERLINK "mailto:ab**@ep ost.no"ab**@epo st.no> wrote in
message
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

--
Outgoing mail is certified Virus Free.
Checked by AVG Anti-Virus (http://www.grisoft.com).
Version: 7.0.230 / Virus Database: 263.0.0 - Release Date: 6/2/2004


--
Outgoing mail is certified Virus Free.
Checked by AVG Anti-Virus (http://www.grisoft.com).
Version: 7.0.230 / Virus Database: 263.0.0 - Release Date: 6/2/2004
Nov 20 '05 #8
System.IndexOut OfRangeExceptio n: It doesnt exist any row at placing 2.

at System.Data.Dat aView.GetRecord (Int32 recordIndex)

at System.Data.Dat aView.IsOrigina lVersion(Int32 index)

at System.Data.Dat aRowView.SetCol umnValue(DataCo lumn column, Object value)

at System.Data.Dat aRowView.set_It em(String property, Object value)

at Test.Form1.btnE dit_Click(Objec t sender, EventArgs e) in
D:\VBNet\Test\T est\Form1.vb:li ne 1825

"Ken Tucker [MVP]" <vb***@bellsout h.net> skrev i melding
news:eW******** ******@tk2msftn gp13.phx.gbl...
Hi,

Try this. What is the exact error message printed in the output
window.

Dim drv As DataRowView

For Each drv In dv
Try
drv.BeginEdit()
drv.Item("Posta lCode") = "2345"
drv.EndEdit()
Catch ex As Exception
Trace.WriteLine (ex.ToString)
End Try
Next

Ken
---------------

"Able" <ab**@epost.n o> wrote in message
news:_K******** ***********@new s2.e.nsc.no:
My DataView has 3 rows and error occurs on editing second row.

Regards Able

"Ken Tucker [MVP]" <HYPERLINK
"mailto:vb***@b ellsouth.net"vb ***@bellsouth.n et> skrev i melding
news:uC******** ******@tk2msftn gp13.phx.gbl...
Hi,

This example uses a dataview dv.

Dim drv As DataRowView

For Each drv In dv
drv.BeginEdit()
drv.Item("Posta lCode") = "2345"
drv.EndEdit()
Next

Ken
------------------

"Able" <HYPERLINK "mailto:ab**@ep ost.no"ab**@epo st.no> wrote in
message
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
>

--
Outgoing mail is certified Virus Free.
Checked by AVG Anti-Virus (http://www.grisoft.com).
Version: 7.0.230 / Virus Database: 263.0.0 - Release Date: 6/2/2004


--
Outgoing mail is certified Virus Free.
Checked by AVG Anti-Virus (http://www.grisoft.com).
Version: 7.0.230 / Virus Database: 263.0.0 - Release Date: 6/2/2004

Nov 20 '05 #9
Hi Able,

This gives me 3 rows in a datagrid with 9800 London

So there should be something else wrong.

\\\\
Dim dt As New DataTable("tblC ustomers")
dt.Columns.Add( "fldZipCode ")
dt.Columns.Add( "City")
For i As Integer = 0 To 2
Dim dr As DataRow = dt.NewRow
dr("City") = "Amsterdam"
dt.Rows.Add(dr)
Dim drt As DataRow = dt.NewRow
drt("City") = "London"
dt.Rows.Add(drt )
Next
Dim dv As New DataView(dt)
dv.RowFilter = "City = 'London'"
For i As Integer = 0 To dv.Count - 1
dv(i)("fldZipCo de") = "9800"
Next
DataGrid1.DataS ource = dv
///

I hope this helps?

Cor
Nov 20 '05 #10

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

Similar topics

0
1224
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
3648
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
1955
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
9554
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
9376
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
10136
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
9988
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...
0
9811
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...
1
7358
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
1
3911
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
3
3509
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2788
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.