Beginning the march

B

BobAchgill

Why do I get this syntax error for the code below:

SYNTAX ERROR MESSAGE:

'myTableinDS' is not a member of 'System.Data.Dataset'

I know the data set is good because when it is read in it
shows up in my datagrid. Now I just want to march
through the table row by row column by column
programmatically doing things with the table data.

But I don't seem to be able to create the variable
MyTableRows() As DataRow to get this process started.

Many thanks!

Bob

+++++++++++++++++++++++++++

CODE:
Dim myDS As DataSet = New DataSet

myDS.ReadXml("MyData_data.xml")

Dim MyTableRows() As DataRow = myDS.myTableinDS()


Dim myCol As DataColumn
Dim myRow As DataRow


If (MyTableRows.Length < 1) Then
'Console.WriteLine("No Rows Found")
Else
For Each myRow In MyTableRows
For Each myCol In myDS.myTableinDS.Columns
'Console.Write(vbTab & myRow
(myCol).ToString())
Next
Next
End If
 
P

Peter Proost

Hi,

what's myTableinDS? Is it a string containing the tablename?

Try this (out of my head so watch typeO's):
Dim myDS As New DataSet
Dim MyTableRows As DataRow
Dim row, col as Integer
myDS.ReadXml("MyData_data.xml")


If (myDS .Tables(myTableinDS).Rows.count =0) Then
'Console.WriteLine("No Rows Found")
Else
For row = 0 to myDS .Tables(myTableinDS).Rows.count -1
For col = 0 to myDS .Tables(myTableinDS).Columns.count -1

'Console.Write(myDS.Tables(myTableinDS).Rows(row).Item(col))
Next
Next
End If


Hth Peter
 
C

Cor Ligthert

Bob,

That it is showed in the datagrid, does not say that it is a dataset, it can
be every IList implementing array or collection however because of the name
probably a DataTable.

I hope this helps

Cor
 
B

BobAchgill

Ok.

I plugged in the actual table name that is in my XML
schema into the code you gave me. But now I get the
ERROR:
Name 'IP_addresses' is not declared.

I wonder if this has anything to do with my XML file that
I read in??

We are reading in the the data XML file. Maybe we should
be reading in the associated Schema XML file???
Otherwise how will the IDE know what the table name is?

CODE:

Dim myDS As New DataSet
Dim MyTableRows As DataRow
Dim row, col As Integer
myDS.ReadXml("IP_addresses_data.xml")


If (myDS.Tables(IP_addresses).Rows.count = 0) Then
'Console.WriteLine("No Rows Found")
Else
For row = 0 To myDS.Tables
(IP_addresses).Rows.count - 1
For col = 0 To myDS.Tables
(IP_addresses).Columns.count - 1

'TextBox1.Text = myDS.Tables
(IP_addresses).Rows(row).Item(col)
'Console.Write(myDS.Tables
(myTableinDS).Rows(row).Item(col))
Next
Next
End If
 
C

Chris Dunaway

The compiler sees IP_addresses as a *variable name* which is not
defined. If that is the table name, then, perhaps, it should be in
quotation marks?

If (myDS.Tables("IP_addresses").Rows.count = 0 Then
.....

Chris
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top