473,597 Members | 2,167 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Updating a row in a dataset

The example for updating an non-strong typed dataset in the resource kit
shows:
dsNorthwind.Tab les("ProductsDS ").Rows(lstResu lts.SelectedInd ex)("ProductNam e
") = ProductName & " - Updated"
My code is something like this:

for each srcrow in myds.table(0)
.. do some stuff ..
myds.table(0).r ows(rownumber)( "fieldname" ) = 1 <== Question is here
next

I don't have a SelectedIndex to use as a row number. How do I address the
current row? Rows does not have an "itemindex" , "currentrow ", etc.
property. What do I do?

Jeremy
Nov 20 '05 #1
3 1001
You are already doing a for each, with a 'srcrow' variable, so just use that
to set the field.

If you want to index by number, you have to use a regular for loop, and use
the for variable to index in.

"Jeremy" <je****@ninprod ata.com> wrote in message
news:Oh******** ******@TK2MSFTN GP09.phx.gbl...
The example for updating an non-strong typed dataset in the resource kit
shows:
dsNorthwind.Tab les("ProductsDS ").Rows(lstResu lts.SelectedInd ex)("ProductNam e ") = ProductName & " - Updated"
My code is something like this:

for each srcrow in myds.table(0)
.. do some stuff ..
myds.table(0).r ows(rownumber)( "fieldname" ) = 1 <== Question is here
next

I don't have a SelectedIndex to use as a row number. How do I address the
current row? Rows does not have an "itemindex" , "currentrow ", etc.
property. What do I do?

Jeremy

Nov 20 '05 #2
Marina, so you're saying that the following does update the dataset?

srcrow("fieldna me") = 1

I did try that, so I must have an issue with the update method then.

Thanks.
"Marina" <mz*******@hotm ail.com> wrote in message
news:uE******** ******@TK2MSFTN GP12.phx.gbl...
You are already doing a for each, with a 'srcrow' variable, so just use that to set the field.

If you want to index by number, you have to use a regular for loop, and use the for variable to index in.

"Jeremy" <je****@ninprod ata.com> wrote in message
news:Oh******** ******@TK2MSFTN GP09.phx.gbl...
The example for updating an non-strong typed dataset in the resource kit
shows:

dsNorthwind.Tab les("ProductsDS ").Rows(lstResu lts.SelectedInd ex)("ProductNam e
") = ProductName & " - Updated"
My code is something like this:

for each srcrow in myds.table(0)
.. do some stuff ..
myds.table(0).r ows(rownumber)( "fieldname" ) = 1 <== Question is here
next

I don't have a SelectedIndex to use as a row number. How do I address the current row? Rows does not have an "itemindex" , "currentrow ", etc.
property. What do I do?

Jeremy


Nov 20 '05 #3
Cor
Hi Jeremy,
Marina, so you're saying that the following does update the dataset?

srcrow("fieldna me") = 1

I did try that, so I must have an issue with the update method then.


Yes

If you want to test it, set a

messagebox.show (scrow("fieldna me").tostring ) behind it.

Just to attent you, that "fieldname" is a pseudo?

Cor
Nov 20 '05 #4

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

Similar topics

0
921
by: Robin | last post by:
In a .Net solution that has a DAL, Class and Business logic. When recreating a dataset from the class the records are inserted into the database from the dataset instead of updating. This is using the dataset merge command. Is there any settings that should be used to ensure that the data is updating instead of inserted?
5
2020
by: junglist | last post by:
Hi guys, I've been trying to implement an editable datagrid and i have been succesful up to the point where i can update my datagrid row by row. However what used to happen was that once i updated one row, all of them were updated so i immediatelly figured out that i have to include the id of every entry in the update statement. This is where the problem is raised. My database is an Access database. The table i am updating contains a Date...
10
5649
by: jaYPee | last post by:
does anyone experienced slowness when updating a dataset using AcceptChanges? when calling this code it takes many seconds to update the database SqlDataAdapter1.Update(DsStudentCourse1) DsStudentCourse1.AcceptChanges() i'm also wondering because w/ out AcceptChanges the data is still save into the database and it is now faster.
14
2114
by: Lars Netzel | last post by:
A little background: I use three Datagrids that are in a child parent relation. I Use Negative Autoincrement on the the DataTables and that's workning nice. My problem is when I Update these grid and write to the database and I set the new Primary Keys and related Fields to the new asigned atuonumbers in the Access.
4
2367
by: Geoff | last post by:
Hi I'm hoping somebody can help me with the following problem that has occurred to me. Suppose I have two tables in an SQL Server database. Let's call these tables A and B. Assume that A has two fields: a primary key and another holding a string. In table B there are three fields: a primary key, a foreign key (which links to the primary key in A) and other field holding a string.
2
13948
by: susan.f.barrett | last post by:
Hi, Despite me being able to type the following in to SQL Server and it updating 1 row: > updatestockcategory 1093, 839 In my code, it is not updating any rows. dataSet = new DataSet();
6
13986
by: Rich | last post by:
Dim da As New SqlDataAdapter("Select * from tbl1", conn) dim tblx As New DataTable da.Fill(tblx) '--works OK up to this point da.UpdateCommand = New SqlCommand da.UpdateCommand.Connection = conn da.UpdateCommand.CommandText = "Update tbl1 set fld1 = 'test' where ID = 1" da.Update(tblx) '--tblx/tbl1 not getting updated here.
6
2325
by: mike11d11 | last post by:
I'm trying to create an application that will have multiple users working off a table on a SQL server. Since multi users will be updating different records at any given moment, how can i get those changes and merge them into my current Dataset. I've been playing around with the GetChanges method and Acceptchanges but they just dont seem to be pulling over the changes and updating my Dataset. Maybe if someone could give me a sample of...
0
1688
by: OldStd | last post by:
Updating data using 2 data sets I am having some problems in updating the database using two datasets as suggested by someone. 1. Data is displayed in a data grid from a dataset generated using the IDE that pulls data from two tables using an . The idea is to display the associated with the field. Because an is used, the IDE couldn’t auto-generate the Insert command, update command, or Delete command. 2. As a result, it was suggested...
1
2359
by: jonbartlam | last post by:
Hi There I'm not sure what exactly is going wrong here. I'm writing an application that retreives a table from a database (tbl_internalfaults) and updates it. (Actually, just the status column will need updating with 'CLOSED' where necessary.) I have been trying to use the OLEDB command builder to build the statement to update the database however it is returning an error whenever I try to do this. I already have a dataset full of data, 1...
0
7962
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
7884
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
8267
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
8024
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,...
1
5844
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...
0
5423
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
3880
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...
0
3921
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1493
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.