|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Iterating through the records in a datasetHi all,
I am new to vb.net and I am trying to use the vb.net components, rather than relying on the VB6 compatibility stuff with which I am more familiar. However, I seem to have fallen at the first hurdle. I have created a dataset linked to a single SQL table and would like to iterate through the records in it, it, changing one of the fields as I go, but I can't seem to find a way of doing this. I guess all the records are in a collection of some sort but I can't seem to access them. Any help gratefully received. Thanks Mark Collection of rows.
For Each row as DataRow in theDataSet.Tables[0].Rows mark blackall wrote: Show quoteHide quote > Hi all, > > I am new to vb.net and I am trying to use the vb.net components, rather than > relying on the VB6 compatibility stuff with which I am more familiar. > > However, I seem to have fallen at the first hurdle. I have created a > dataset linked to a single SQL table and would like to iterate through the > records in it, it, changing one of the fields as I go, but I can't seem to > find a way of doing this. I guess all the records are in a collection of > some sort but I can't seem to access them. > > Any help gratefully received. > > Thanks > > Mark
Show quote
Hide quote
"mark blackall" <black***@btinternet.com> wrote in message I had trouble understanding ADO.Net when I switched from ADODB using VB6 :)news:edm939$nk4$1$830fa7a5@news.demon.co.uk... > Hi all, > > I am new to vb.net and I am trying to use the vb.net components, rather > than relying on the VB6 compatibility stuff with which I am more familiar. > > However, I seem to have fallen at the first hurdle. I have created a > dataset linked to a single SQL table and would like to iterate through the > records in it, it, changing one of the fields as I go, but I can't seem to > find a way of doing this. I guess all the records are in a collection of > some sort but I can't seem to access them. > > Any help gratefully received. > > Thanks > > Mark > > Look at the big differences between the two in order to help understand them. ADODB contain recordsets that you can update directly and calling a single Update method on the Recordset will update the database. ADO.Net has no such method. A DataSet is NOT a recordset, nor should it be used as one. It helps me to see a DataSet as an in-memory database. Just like a db, the DataSet contains tables (stores of data). The DataTable
Show quote
Hide quote
"mark blackall" <black***@btinternet.com> wrote in message Oops, ignore my previous post...darn shift-enter!!!news:edm939$nk4$1$830fa7a5@news.demon.co.uk... > Hi all, > > I am new to vb.net and I am trying to use the vb.net components, rather > than relying on the VB6 compatibility stuff with which I am more familiar. > > However, I seem to have fallen at the first hurdle. I have created a > dataset linked to a single SQL table and would like to iterate through the > records in it, it, changing one of the fields as I go, but I can't seem to > find a way of doing this. I guess all the records are in a collection of > some sort but I can't seem to access them. > > Any help gratefully received. > > Thanks > > Mark > > What helps me is looking at DataSets as small, in-memory databases. Each DataSet can contain one or more DataTable instances. Each DataTable contain DataRows. The rows, when updated, do NOT update the SQL Server (or other dbms) automatically. Instead, the in-memory db (DataSet/DataTable/DataRow) is updated. When you want to commit (Update) the real dbms, you will need to connect to the database (if no connection exists already), and using the DataAdapter (ie: SqlDataAdapter) call the appropriate Update/Insert methods passing either the DataRow, DataTable, or DataSet (forget which is required). Once you do get a handle on ADO.Net, I would recommend looking into the Microsoft Patterns and Practices Enterprise Library Application Blocks (more specifically, the Data Access Application Block). These blocks help streamline code you would normally write to help normalize database connection and access. HTH, Mythran
Registry Reading
Remove certain characters from a string/RichTextBox? Better way to process many conditions with If Then Crystal Reports in VB.NET Determining max number of characters in a TextBox Save Radio Button setting how to get a file to display from relative filespec Deleting a folder SQL Server Intellisense XML Comments / Documentation |
|||||||||||||||||||||||