What is the proper way to refer to a dataset as the
collection in a For Each, Next Statement? I want to loop
through a particular column in the dataset, I've tried
the following with no sucess.
For Each x as integer in Dataset1
....
....
....
Next x
But the dataset name is not a valid collection type.
I appreciate your help, Seasons Greetings 7 2864
"Nitromuse" <an*******@discussions.microsoft.com> schrieb What is the proper way to refer to a dataset as the collection in a For Each, Next Statement? I want to loop through a particular column in the dataset, I've tried the following with no sucess.
For Each x as integer in Dataset1 .... .... .... Next x
But the dataset name is not a valid collection type. I appreciate your help, Seasons Greetings
dim row as datarow
for each row in dataset1.tables("tablename").rows
debug.writeline row("columnname")
next
I assume Dataset1 is the name of the variable referencing the Dataset
object.
--
Armin http://www.plig.net/nnq/nquote.html http://www.netmeister.org/news/learn2quote.html
Thanks for the help Armin, I'm using the following and
getting a 'Object reference not set to an instance of an
object' at the For Each line, what am I missing.
Private Sub Button10_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
Button10.Click
Dim row As DataRow
Dim ds As DataSet
ds = New System.Data.DataSet("Payroll.DataSet1")
For Each row In ds.Tables("Payroll.DataSet1").Rows
Debug.WriteLine(row("columnname"))
Next
End Sub
Thanks again, -----Original Message----- "Nitromuse" <an*******@discussions.microsoft.com> schrieb What is the proper way to refer to a dataset as the collection in a For Each, Next Statement? I want to
loop through a particular column in the dataset, I've tried the following with no sucess.
For Each x as integer in Dataset1 .... .... .... Next x
But the dataset name is not a valid collection type. I appreciate your help, Seasons Greetings dim row as datarow
for each row in dataset1.tables("tablename").rows debug.writeline row("columnname") next
I assume Dataset1 is the name of the variable
referencing the Datasetobject.
-- Armin
http://www.plig.net/nnq/nquote.html http://www.netmeister.org/news/learn2quote.html
.
Once again, thank you! I've filled the dataset with a
dataAdapter and fill command before running the sub I
referenced, (which I didn't include in the previous
message). I think I'm just missing how to re-instanciate
the object properly.
Again, THANX -----Original Message----- "Nitromuse" <an*******@discussions.microsoft.com> schrieb Thanks for the help Armin, I'm using the following and getting a 'Object reference not set to an instance of
an object' at the For Each line, what am I missing.
Private Sub Button10_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button10.Click Dim row As DataRow Dim ds As DataSet ds = New System.Data.DataSet
("Payroll.DataSet1") For Each row In ds.Tables
("Payroll.DataSet1").Rows Debug.WriteLine(row("columnname")) Next End Sub Thanks again,
You do not add any tables to the Dataset. You also don't
fill the Datasetwith records. If the Dataset is completely empty, using
For-Next doesn'tmake sense.
How to use datasets: http://msdn.microsoft.com/library/en-
us/cpguide/html/cpconcreatingusingdatasets.asphttp://msdn.microsoft.com/library/en-
us/vbcon/html/vboriDatasets.asp
-- Armin
http://www.plig.net/nnq/nquote.html http://www.netmeister.org/news/learn2quote.html
.
Hi Nit,
Here's a very basic example of how to fill a dataset with data before
looping through it:
Dim oconn As New SqlConnection("data source=d5z0071;database=imc;integrated
security=sspi;")
Dim dabnlsum As New SqlDataAdapter("select distinct invnum from bnlsum order
by invnum", oconn)
Dim dsbnlsum As New DataSet("bnlsum")
oconn.Open()
dabnlsum.Fill(dsbnlsum, "bnlsum")
Dim irow As DataRow
For Each irow In dsbnlsum.Tables(0).Rows
etc
HTH,
Bernie Yaeger
"Nitromuse" <an*******@discussions.microsoft.com> wrote in message
news:00****************************@phx.gbl... Thanks for the help Armin, I'm using the following and getting a 'Object reference not set to an instance of an object' at the For Each line, what am I missing.
Private Sub Button10_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button10.Click Dim row As DataRow Dim ds As DataSet ds = New System.Data.DataSet("Payroll.DataSet1") For Each row In ds.Tables("Payroll.DataSet1").Rows Debug.WriteLine(row("columnname")) Next End Sub Thanks again,
-----Original Message----- "Nitromuse" <an*******@discussions.microsoft.com> schrieb What is the proper way to refer to a dataset as the collection in a For Each, Next Statement? I want to loop through a particular column in the dataset, I've tried the following with no sucess.
For Each x as integer in Dataset1 .... .... .... Next x
But the dataset name is not a valid collection type. I appreciate your help, Seasons Greetings
dim row as datarow
for each row in dataset1.tables("tablename").rows debug.writeline row("columnname") next
I assume Dataset1 is the name of the variable referencing the Datasetobject.
-- Armin
http://www.plig.net/nnq/nquote.html http://www.netmeister.org/news/learn2quote.html
.
Hi,
Dim conn As OleDbConnection
Dim strConn As String
Dim strSQL As String
Dim da As OleDbDataAdapter
strConn = "Provider = Microsoft.Jet.OLEDB.4.0;"
strConn += "Data Source = Northwind.mdb;"
conn = New OleDbConnection(strConn)
da = New OleDbDataAdapter("Select * From Categories", conn)
da.Fill(ds, "Categories")
For Each dr As DataRow In ds.Tables("Categories").Rows
Debug.WriteLine(dr.Item("CategoryName"))
Next
Ken
----------------------
"Nitromuse" <an*******@discussions.microsoft.com> wrote in message
news:01****************************@phx.gbl... Once again, thank you! I've filled the dataset with a dataAdapter and fill command before running the sub I referenced, (which I didn't include in the previous message). I think I'm just missing how to re-instanciate the object properly. Again, THANX
-----Original Message----- "Nitromuse" <an*******@discussions.microsoft.com> schrieb Thanks for the help Armin, I'm using the following and getting a 'Object reference not set to an instance of an object' at the For Each line, what am I missing.
Private Sub Button10_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button10.Click Dim row As DataRow Dim ds As DataSet ds = New System.Data.DataSet ("Payroll.DataSet1") For Each row In ds.Tables ("Payroll.DataSet1").Rows Debug.WriteLine(row("columnname")) Next End Sub Thanks again,
You do not add any tables to the Dataset. You also don't fill the Datasetwith records. If the Dataset is completely empty, using For-Next doesn'tmake sense.
How to use datasets: http://msdn.microsoft.com/library/en- us/cpguide/html/cpconcreatingusingdatasets.asphttp://msdn.microsoft.com/library/en- us/vbcon/html/vboriDatasets.asp
-- Armin
http://www.plig.net/nnq/nquote.html http://www.netmeister.org/news/learn2quote.html
.
Thanks Ken, thanks Armin
It was simply the line;
For Each dr As DataRow In DataSet11.Tables("Comp").Rows
that I didn't understand as how to refer to the row in a
dataset. Thanks again, -----Original Message----- Hi,
Dim conn As OleDbConnection
Dim strConn As String
Dim strSQL As String
Dim da As OleDbDataAdapter
strConn = "Provider = Microsoft.Jet.OLEDB.4.0;"
strConn += "Data Source = Northwind.mdb;"
conn = New OleDbConnection(strConn)
da = New OleDbDataAdapter("Select * From Categories",
conn) da.Fill(ds, "Categories")
For Each dr As DataRow In ds.Tables("Categories").Rows
Debug.WriteLine(dr.Item("CategoryName"))
Next
Ken
----------------------
"Nitromuse" <an*******@discussions.microsoft.com> wrote
in messagenews:01****************************@phx.gbl... Once again, thank you! I've filled the dataset with a dataAdapter and fill command before running the sub I referenced, (which I didn't include in the previous message). I think I'm just missing how to re-
instanciate the object properly. Again, THANX
-----Original Message----- "Nitromuse" <an*******@discussions.microsoft.com>
schrieb Thanks for the help Armin, I'm using the following
and getting a 'Object reference not set to an instance of an object' at the For Each line, what am I missing.
Private Sub Button10_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button10.Click Dim row As DataRow Dim ds As DataSet ds = New System.Data.DataSet ("Payroll.DataSet1") For Each row In ds.Tables ("Payroll.DataSet1").Rows Debug.WriteLine(row("columnname")) Next End Sub Thanks again,
You do not add any tables to the Dataset. You also
don't fill the Datasetwith records. If the Dataset is completely empty, using For-Next doesn'tmake sense.
How to use datasets: http://msdn.microsoft.com/library/en- us/cpguide/html/cpconcreatingusingdatasets.asphttp://msdn.microsoft.com/library/en- us/vbcon/html/vboriDatasets.asp
-- Armin
http://www.plig.net/nnq/nquote.html http://www.netmeister.org/news/learn2quote.html
.
. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: George Grodentzik |
last post by:
I created a typed dataset from which I am trying to access the data. When I use the following code to access a row
string name =dataset.person.firstName
I receive an error...
|
by: DotNetJunkies User |
last post by:
Hi all,
I have a question on how can I write the entire Dataset to a NTEXT field of SQLServer.
Can anyone help me?
Thanks!
/mike
|
by: dSchwartz |
last post by:
I need help adding a column to a dataset, but its a little bit more
complicated then just that. Here's the situation: I have many xml
files in one directory, each which represent a newsletter. I...
|
by: dauphian |
last post by:
Hello,
I am new to .net and am trying to build a report application that
queries 4 different tables based on a id, and I need to return them in
the same table for easy viewing.
Basically, I...
|
by: JIM.H. |
last post by:
Hello,
How can I loop table names in a dataset?
Thanks,
|
by: martin1 |
last post by:
Hi,
want to loop DataSet to change row background color based on data retrieved
from sql db, the color can be blue, yellow, red or purple. Therefore, Is
there any way (vb.net) to change dataset...
|
by: fniles |
last post by:
I am using VB.NET 2003, SQL 2000, and SqlDataAdapter.
For every record in tblA where colB = 'abc', I want to update the value in
colA.
In VB6, using ADO I can loop thru the recordset,set the...
|
by: David |
last post by:
Hi all,
Using C# 1.1
I have a dataset loaded from an XML file. The idea being that if the app (a
winform app that relies on a webservice) is offline, then I save data
locally in XML and...
|
by: tshad |
last post by:
Is there a way to update a DataSet Object?
I have a Dataset Object (DataSetObj.Tables(0) - one table) that I read in
from a .csv file.
I normally do the following to get my data from the .csv:...
|
by: Ken Fine |
last post by:
This is a question that someone familiar with ASP.NET and ADO.NET DataSets
and DataTables should be able to answer fairly easily. The basic question is
how I can efficiently match data from one...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
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,...
|
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...
|
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,...
|
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...
|
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...
| |