Datagrid doesn't show XML data

D

David Fúnez

I have a little APP for an iPAQ that runs Ok but it does not show any
record, the problem is with the XML File as shown.

The APP is a DataGrid and two Buttons, one to save data an one to exit the
App.

So, any help will be wellcome.

**** The Code *****
Dim dsLibros As DataSet
Dim dtPrestados As DataTable
Dim xmlFile As String = "Libros.xml"

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
dtPrestados = New DataTable("prestados")
dtPrestados.Columns.Add("Id", GetType(Integer))
dtPrestados.Columns.Add("Titulo", GetType(String))
dtPrestados.Columns.Add("prestadosA", GetType(String))
dtPrestados.Columns.Add("Fecha", GetType(Date))
dtPrestados.Columns.Add("Devuelto", GetType(Boolean))

With dtPrestados.Columns("id")
.AutoIncrement = True
.AutoIncrementSeed = 1
End With

dsLibros = New DataSet("Libros")
dsLibros.Tables.Add(dtPrestados)

dgLibros.DataSource = dsLibros.Tables(0) ' that's Ok, it shows the
columns

******* Mi problem is here, if i use this routine:

If File.Exists(xmlFile) Then
dsLibros.ReadXml(xmlFile)
Else
MsgBox("File doesn't exists")
End If

******* shows the File doesn't exists Message,

******* if i put this line: dsLibros.ReadXml(xmlFile) **** out of the
routine like this

*** dgLibros.DataSource = dsLibros.Tables(0)
*** dsLibros.ReadXml(xmlFile)

*** it lounches an error

End Sub

Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnExit.Click
Me.Close()
End Sub

Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnSave.Click
dsLibros.WriteXml(xmlFile)
End Sub
 
I

Ilya Tumanov [MS]

You can't load XML file because relative paths are not supported on CE.
Full path needs to be specified.
If your XML is in the same folder as your EXE, you can use this to
determine the path to your application.
That would allow you to construct a full path to the XML file.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dncfhowto/h
tml/HOWTOExecutingAppPath.asp

Best regards,

Ilya

This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
 
G

Guest

The Windows CE doesn't have a notion of current directory, so when accessing
files you must provide a full path.
 
D

David Fúnez

OK;

I've added this to get the path, but it still doesn't find ten XML File:

Dim path As String
path = System.IO.Path.GetDirectoryName( _
System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase)

MessageBox.Show(path & "\" & xmlFile)

If File.Exists(path & "\" & xmlFile) Then
dsLibros.ReadXml(path & "\" & xmlFile)
Else
MsgBox("no encontró el archivo")
End If

**********************
This File "Libros.xml" is in [C:\DotNet\iPAQ] folder and is added to my
project.

The result folder is "\Program Files\iPAQ"

at the end of the compile shows "Libros.xml" has been copied, but it doesn't
show where.
 
D

David Fúnez

I tried This:

dsLibros.ReadXml("\Program Files\iPAQ\libros.xml")

Now it doesn't show any error, but doesn't show any data in the DataGrid.

Any help.
 
I

Ilya Tumanov [MS]

Do you have any data in the XML? If you do, it has to match your schema.
Print out number of rows to see if data has been loaded.
It's also a good idea to try it on desktop first.

Best regards,

Ilya

This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
 
D

David Fúnez

Yes, the Xml file has data, but i have no created a Xsd file. ¿do i need
it?.

First i tried in desktop mode, and works very well.

Thanks on advance.

--
David Fúnez
Tegucigalpa, Honduras


"Ilya Tumanov [MS]" said:
Do you have any data in the XML? If you do, it has to match your schema.
Print out number of rows to see if data has been loaded.
It's also a good idea to try it on desktop first.

Best regards,

Ilya

This posting is provided "AS IS" with no warranties, and confers no
rights.
--------------------
 
I

Ilya Tumanov [MS]

Do you mean this very code (with path correction) works on a desktop?
Or was a similar project with, say, typed dataset?

If you do this after ReadXml():
MessageBox.Show(dsLibros.Tables(0).Rows.Count.ToString())
Is number in a message box above zero?

As to XSD file, you can load it into empty DataSet instead of creating
schema programmatically (which is also fine as long as it matches XML):

dsLibros = New DataSet()
dsLibros.ReadXmlSchema ("FULL_PATH_TO_XSD_FILE") 'Creates all tables and
columns according to schema file.
dsLibros.ReadXml ("FULL_PATH_TO_XML_FILE") 'Loads data, XML needs to match
XSD schema loaded before.
dgLibros.DataSource = dsLibros.Tables(0) 'Show data in the grid.

The benefit is what you can tweak the schema easily.

Best regards,

Ilya

This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
Reply-To: "David Fúnez" <[email protected]>
From: "David Fúnez" <[email protected]>
References: <[email protected]>
Subject: Re: Datagrid doesn't show XML data
Date: Tue, 28 Dec 2004 16:47:21 -0600
Lines: 141
Organization: Income
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.2527
X-RFC2646: Format=Flowed; Original
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2527
Message-ID: <[email protected]>
Newsgroups: microsoft.public.dotnet.framework.compactframework
NNTP-Posting-Host: 205-240-200-123.reverse.cablecolor.hn 205.240.200.123
Path: cpmsftngxa10.phx.gbl!TK2MSFTFEED01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP15
.phx.gbl
Xref: cpmsftngxa10.phx.gbl microsoft.public.dotnet.framework.compactframework:67663
X-Tomcat-NG: microsoft.public.dotnet.framework.compactframework

Yes, the Xml file has data, but i have no created a Xsd file. ¿do i need
it?.

First i tried in desktop mode, and works very well.

Thanks on advance.

--
David Fúnez
Tegucigalpa, Honduras


"Ilya Tumanov [MS]" said:
Do you have any data in the XML? If you do, it has to match your schema.
Print out number of rows to see if data has been loaded.
It's also a good idea to try it on desktop first.

Best regards,

Ilya

This posting is provided "AS IS" with no warranties, and confers no
rights.
--------------------
Reply-To: "David Fúnez" <[email protected]>
From: "David Fúnez" <[email protected]>
References: <[email protected]>
Subject: Re: Datagrid doesn't show XML data
Date: Tue, 28 Dec 2004 15:50:12 -0600
Lines: 87
Organization: Income
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.2527
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2527
X-RFC2646: Format=Flowed; Response
Message-ID: <[email protected]>
Newsgroups: microsoft.public.dotnet.framework.compactframework
NNTP-Posting-Host: 205-240-200-116.reverse.cablecolor.hn 205.240.200.116
Path:
cpmsftngxa10.phx.gbl!TK2MSFTFEED02.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP11
phx.gbl
Xref: cpmsftngxa10.phx.gbl microsoft.public.dotnet.framework.compactframework:67657
X-Tomcat-NG: microsoft.public.dotnet.framework.compactframework

I tried This:

dsLibros.ReadXml("\Program Files\iPAQ\libros.xml")

Now it doesn't show any error, but doesn't show any data in the DataGrid.

Any help.

--
David Fúnez
Tegucigalpa, Honduras


I have a little APP for an iPAQ that runs Ok but it does not show any
record, the problem is with the XML File as shown.

The APP is a DataGrid and two Buttons, one to save data an one to
exit
the
App.

So, any help will be wellcome.

**** The Code *****
Dim dsLibros As DataSet
Dim dtPrestados As DataTable
Dim xmlFile As String = "Libros.xml"

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
dtPrestados = New DataTable("prestados")
dtPrestados.Columns.Add("Id", GetType(Integer))
dtPrestados.Columns.Add("Titulo", GetType(String))
dtPrestados.Columns.Add("prestadosA", GetType(String))
dtPrestados.Columns.Add("Fecha", GetType(Date))
dtPrestados.Columns.Add("Devuelto", GetType(Boolean))

With dtPrestados.Columns("id")
.AutoIncrement = True
.AutoIncrementSeed = 1
End With

dsLibros = New DataSet("Libros")
dsLibros.Tables.Add(dtPrestados)

dgLibros.DataSource = dsLibros.Tables(0) ' that's Ok, it shows the
columns

******* Mi problem is here, if i use this routine:

If File.Exists(xmlFile) Then
dsLibros.ReadXml(xmlFile)
Else
MsgBox("File doesn't exists")
End If

******* shows the File doesn't exists Message,

******* if i put this line: dsLibros.ReadXml(xmlFile) **** out
of
the
routine like this

*** dgLibros.DataSource = dsLibros.Tables(0)
*** dsLibros.ReadXml(xmlFile)

*** it lounches an error

End Sub

Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnExit.Click
Me.Close()
End Sub

Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnSave.Click
dsLibros.WriteXml(xmlFile)
End Sub
 
D

David Fúnez

i mean that this code works ok in the Windows Form App i built at First,
this one is other project form Smart Devices.

I'll try what tou say... thanks a lot.

--
David Fúnez
Tegucigalpa, Honduras


"Ilya Tumanov [MS]" said:
Do you mean this very code (with path correction) works on a desktop?
Or was a similar project with, say, typed dataset?

If you do this after ReadXml():
MessageBox.Show(dsLibros.Tables(0).Rows.Count.ToString())
Is number in a message box above zero?

As to XSD file, you can load it into empty DataSet instead of creating
schema programmatically (which is also fine as long as it matches XML):

dsLibros = New DataSet()
dsLibros.ReadXmlSchema ("FULL_PATH_TO_XSD_FILE") 'Creates all tables and
columns according to schema file.
dsLibros.ReadXml ("FULL_PATH_TO_XML_FILE") 'Loads data, XML needs to match
XSD schema loaded before.
dgLibros.DataSource = dsLibros.Tables(0) 'Show data in the grid.

The benefit is what you can tweak the schema easily.

Best regards,

Ilya

This posting is provided "AS IS" with no warranties, and confers no
rights.

--------------------
Reply-To: "David Fúnez" <[email protected]>
From: "David Fúnez" <[email protected]>
References: <[email protected]>
Subject: Re: Datagrid doesn't show XML data
Date: Tue, 28 Dec 2004 16:47:21 -0600
Lines: 141
Organization: Income
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.2527
X-RFC2646: Format=Flowed; Original
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2527
Message-ID: <[email protected]>
Newsgroups: microsoft.public.dotnet.framework.compactframework
NNTP-Posting-Host: 205-240-200-123.reverse.cablecolor.hn 205.240.200.123
Path: cpmsftngxa10.phx.gbl!TK2MSFTFEED01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP15
phx.gbl
Xref: cpmsftngxa10.phx.gbl microsoft.public.dotnet.framework.compactframework:67663
X-Tomcat-NG: microsoft.public.dotnet.framework.compactframework

Yes, the Xml file has data, but i have no created a Xsd file. ¿do i need
it?.

First i tried in desktop mode, and works very well.

Thanks on advance.

--
David Fúnez
Tegucigalpa, Honduras


"Ilya Tumanov [MS]" said:
Do you have any data in the XML? If you do, it has to match your
schema.
Print out number of rows to see if data has been loaded.
It's also a good idea to try it on desktop first.

Best regards,

Ilya

This posting is provided "AS IS" with no warranties, and confers no
rights.
--------------------
Reply-To: "David Fúnez" <[email protected]>
From: "David Fúnez" <[email protected]>
References: <[email protected]>
Subject: Re: Datagrid doesn't show XML data
Date: Tue, 28 Dec 2004 15:50:12 -0600
Lines: 87
Organization: Income
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.2527
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2527
X-RFC2646: Format=Flowed; Response
Message-ID: <[email protected]>
Newsgroups: microsoft.public.dotnet.framework.compactframework
NNTP-Posting-Host: 205-240-200-116.reverse.cablecolor.hn 205.240.200.116
Path:
cpmsftngxa10.phx.gbl!TK2MSFTFEED02.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP11
phx.gbl
Xref: cpmsftngxa10.phx.gbl
microsoft.public.dotnet.framework.compactframework:67657
X-Tomcat-NG: microsoft.public.dotnet.framework.compactframework

I tried This:

dsLibros.ReadXml("\Program Files\iPAQ\libros.xml")

Now it doesn't show any error, but doesn't show any data in the DataGrid.

Any help.

--
David Fúnez
Tegucigalpa, Honduras


I have a little APP for an iPAQ that runs Ok but it does not show any
record, the problem is with the XML File as shown.

The APP is a DataGrid and two Buttons, one to save data an one to exit
the
App.

So, any help will be wellcome.

**** The Code *****
Dim dsLibros As DataSet
Dim dtPrestados As DataTable
Dim xmlFile As String = "Libros.xml"

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
dtPrestados = New DataTable("prestados")
dtPrestados.Columns.Add("Id", GetType(Integer))
dtPrestados.Columns.Add("Titulo", GetType(String))
dtPrestados.Columns.Add("prestadosA", GetType(String))
dtPrestados.Columns.Add("Fecha", GetType(Date))
dtPrestados.Columns.Add("Devuelto", GetType(Boolean))

With dtPrestados.Columns("id")
.AutoIncrement = True
.AutoIncrementSeed = 1
End With

dsLibros = New DataSet("Libros")
dsLibros.Tables.Add(dtPrestados)

dgLibros.DataSource = dsLibros.Tables(0) ' that's Ok, it
shows
the
columns

******* Mi problem is here, if i use this routine:

If File.Exists(xmlFile) Then
dsLibros.ReadXml(xmlFile)
Else
MsgBox("File doesn't exists")
End If

******* shows the File doesn't exists Message,

******* if i put this line: dsLibros.ReadXml(xmlFile) **** out of
the
routine like this

*** dgLibros.DataSource = dsLibros.Tables(0)
*** dsLibros.ReadXml(xmlFile)

*** it lounches an error

End Sub

Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnExit.Click
Me.Close()
End Sub

Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnSave.Click
dsLibros.WriteXml(xmlFile)
End Sub
 
D

David Fúnez

This shows 0.

dsLibros.ReadXml(path & "\" & xmlFile)

MessageBox.Show(dsLibros.Tables(0).Rows.Count.ToString())


--
David Fúnez
Tegucigalpa, Honduras


David Fúnez said:
i mean that this code works ok in the Windows Form App i built at First,
this one is other project form Smart Devices.

I'll try what tou say... thanks a lot.

--
David Fúnez
Tegucigalpa, Honduras


"Ilya Tumanov [MS]" said:
Do you mean this very code (with path correction) works on a desktop?
Or was a similar project with, say, typed dataset?

If you do this after ReadXml():
MessageBox.Show(dsLibros.Tables(0).Rows.Count.ToString())
Is number in a message box above zero?

As to XSD file, you can load it into empty DataSet instead of creating
schema programmatically (which is also fine as long as it matches XML):

dsLibros = New DataSet()
dsLibros.ReadXmlSchema ("FULL_PATH_TO_XSD_FILE") 'Creates all tables and
columns according to schema file.
dsLibros.ReadXml ("FULL_PATH_TO_XML_FILE") 'Loads data, XML needs to
match
XSD schema loaded before.
dgLibros.DataSource = dsLibros.Tables(0) 'Show data in the grid.

The benefit is what you can tweak the schema easily.

Best regards,

Ilya

This posting is provided "AS IS" with no warranties, and confers no
rights.

--------------------
Reply-To: "David Fúnez" <[email protected]>
From: "David Fúnez" <[email protected]>
References: <[email protected]>
Subject: Re: Datagrid doesn't show XML data
Date: Tue, 28 Dec 2004 16:47:21 -0600
Lines: 141
Organization: Income
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.2527
X-RFC2646: Format=Flowed; Original
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2527
Message-ID: <[email protected]>
Newsgroups: microsoft.public.dotnet.framework.compactframework
NNTP-Posting-Host: 205-240-200-123.reverse.cablecolor.hn 205.240.200.123
Path: cpmsftngxa10.phx.gbl!TK2MSFTFEED01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP15
phx.gbl
Xref: cpmsftngxa10.phx.gbl microsoft.public.dotnet.framework.compactframework:67663
X-Tomcat-NG: microsoft.public.dotnet.framework.compactframework

Yes, the Xml file has data, but i have no created a Xsd file. ¿do i need
it?.

First i tried in desktop mode, and works very well.

Thanks on advance.

--
David Fúnez
Tegucigalpa, Honduras


Do you have any data in the XML? If you do, it has to match your
schema.
Print out number of rows to see if data has been loaded.
It's also a good idea to try it on desktop first.

Best regards,

Ilya

This posting is provided "AS IS" with no warranties, and confers no
rights.
--------------------
Reply-To: "David Fúnez" <[email protected]>
From: "David Fúnez" <[email protected]>
References: <[email protected]>
Subject: Re: Datagrid doesn't show XML data
Date: Tue, 28 Dec 2004 15:50:12 -0600
Lines: 87
Organization: Income
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.2527
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2527
X-RFC2646: Format=Flowed; Response
Message-ID: <[email protected]>
Newsgroups: microsoft.public.dotnet.framework.compactframework
NNTP-Posting-Host: 205-240-200-116.reverse.cablecolor.hn 205.240.200.116
cpmsftngxa10.phx.gbl!TK2MSFTFEED02.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP11
phx.gbl
Xref: cpmsftngxa10.phx.gbl
microsoft.public.dotnet.framework.compactframework:67657
X-Tomcat-NG: microsoft.public.dotnet.framework.compactframework

I tried This:

dsLibros.ReadXml("\Program Files\iPAQ\libros.xml")

Now it doesn't show any error, but doesn't show any data in the DataGrid.

Any help.

--
David Fúnez
Tegucigalpa, Honduras


I have a little APP for an iPAQ that runs Ok but it does not show
any
record, the problem is with the XML File as shown.

The APP is a DataGrid and two Buttons, one to save data an one to exit
the
App.

So, any help will be wellcome.

**** The Code *****
Dim dsLibros As DataSet
Dim dtPrestados As DataTable
Dim xmlFile As String = "Libros.xml"

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
dtPrestados = New DataTable("prestados")
dtPrestados.Columns.Add("Id", GetType(Integer))
dtPrestados.Columns.Add("Titulo", GetType(String))
dtPrestados.Columns.Add("prestadosA", GetType(String))
dtPrestados.Columns.Add("Fecha", GetType(Date))
dtPrestados.Columns.Add("Devuelto", GetType(Boolean))

With dtPrestados.Columns("id")
.AutoIncrement = True
.AutoIncrementSeed = 1
End With

dsLibros = New DataSet("Libros")
dsLibros.Tables.Add(dtPrestados)

dgLibros.DataSource = dsLibros.Tables(0) ' that's Ok, it
shows
the
columns

******* Mi problem is here, if i use this routine:

If File.Exists(xmlFile) Then
dsLibros.ReadXml(xmlFile)
Else
MsgBox("File doesn't exists")
End If

******* shows the File doesn't exists Message,

******* if i put this line: dsLibros.ReadXml(xmlFile) **** out of
the
routine like this

*** dgLibros.DataSource = dsLibros.Tables(0)
*** dsLibros.ReadXml(xmlFile)

*** it lounches an error

End Sub

Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnExit.Click
Me.Close()
End Sub

Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnSave.Click
dsLibros.WriteXml(xmlFile)
End Sub
 
D

David Fúnez

This Code Works Ok... Thanks a Lot....

Just one more question.... how do i do to Add, Edit and Delete Data in the
DataGrid.?

****** The Code ******
Imports System.Xml
Imports System.IO
Imports System.Windows.Forms

Public Class Form1
Inherits System.Windows.Forms.Form
Friend WithEvents dgLibros As System.Windows.Forms.DataGrid
Friend WithEvents btnSalvar As System.Windows.Forms.Button
Friend WithEvents btnSalir As System.Windows.Forms.Button

#Region " Código generado por el Diseñador de Windows Forms "

Dim dsLibros As New DataSet
Dim xmlFile As String = "libros.xml"
Dim xsdFile As String = "libros.xsd"
Dim path As String = System.IO.Path.GetDirectoryName( _
System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase)

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
If File.Exists(path & "\" & xmlFile) Then
dsLibros.ReadXmlSchema(path & "\" & xsdFile) 'Creates all
tables and columns according to schema file.
dsLibros.ReadXml(path & "\" & xmlFile) 'Loads data, XML needs
to match XSD schema loaded before.
dgLibros.DataSource = dsLibros.Tables(0)
Else
MsgBox("no encontró el archivo")
End If
End Sub

Private Sub btnSalir_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnSalir.Click
Me.Close()
End Sub

Private Sub btnSalvar_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnSalvar.Click
dsLibros.WriteXml(Path & "\" & xmlFile)
End Sub
End Class


--
David Fúnez
Tegucigalpa, Honduras


David Fúnez said:
This shows 0.

dsLibros.ReadXml(path & "\" & xmlFile)

MessageBox.Show(dsLibros.Tables(0).Rows.Count.ToString())


--
David Fúnez
Tegucigalpa, Honduras


David Fúnez said:
i mean that this code works ok in the Windows Form App i built at First,
this one is other project form Smart Devices.

I'll try what tou say... thanks a lot.

--
David Fúnez
Tegucigalpa, Honduras


"Ilya Tumanov [MS]" said:
Do you mean this very code (with path correction) works on a desktop?
Or was a similar project with, say, typed dataset?

If you do this after ReadXml():
MessageBox.Show(dsLibros.Tables(0).Rows.Count.ToString())
Is number in a message box above zero?

As to XSD file, you can load it into empty DataSet instead of creating
schema programmatically (which is also fine as long as it matches XML):

dsLibros = New DataSet()
dsLibros.ReadXmlSchema ("FULL_PATH_TO_XSD_FILE") 'Creates all tables and
columns according to schema file.
dsLibros.ReadXml ("FULL_PATH_TO_XML_FILE") 'Loads data, XML needs to
match
XSD schema loaded before.
dgLibros.DataSource = dsLibros.Tables(0) 'Show data in the grid.

The benefit is what you can tweak the schema easily.

Best regards,

Ilya

This posting is provided "AS IS" with no warranties, and confers no
rights.

--------------------
Reply-To: "David Fúnez" <[email protected]>
From: "David Fúnez" <[email protected]>
References: <[email protected]>
<[email protected]>
<[email protected]>
Subject: Re: Datagrid doesn't show XML data
Date: Tue, 28 Dec 2004 16:47:21 -0600
Lines: 141
Organization: Income
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.2527
X-RFC2646: Format=Flowed; Original
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2527
Message-ID: <[email protected]>
Newsgroups: microsoft.public.dotnet.framework.compactframework
NNTP-Posting-Host: 205-240-200-123.reverse.cablecolor.hn
205.240.200.123
Path:
cpmsftngxa10.phx.gbl!TK2MSFTFEED01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP15
phx.gbl
Xref: cpmsftngxa10.phx.gbl
microsoft.public.dotnet.framework.compactframework:67663
X-Tomcat-NG: microsoft.public.dotnet.framework.compactframework

Yes, the Xml file has data, but i have no created a Xsd file. ¿do i
need
it?.

First i tried in desktop mode, and works very well.

Thanks on advance.

--
David Fúnez
Tegucigalpa, Honduras


Do you have any data in the XML? If you do, it has to match your
schema.
Print out number of rows to see if data has been loaded.
It's also a good idea to try it on desktop first.

Best regards,

Ilya

This posting is provided "AS IS" with no warranties, and confers no
rights.
--------------------
Reply-To: "David Fúnez" <[email protected]>
From: "David Fúnez" <[email protected]>
References: <[email protected]>
Subject: Re: Datagrid doesn't show XML data
Date: Tue, 28 Dec 2004 15:50:12 -0600
Lines: 87
Organization: Income
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.2527
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2527
X-RFC2646: Format=Flowed; Response
Message-ID: <[email protected]>
Newsgroups: microsoft.public.dotnet.framework.compactframework
NNTP-Posting-Host: 205-240-200-116.reverse.cablecolor.hn
205.240.200.116
Path:

cpmsftngxa10.phx.gbl!TK2MSFTFEED02.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP11
phx.gbl
Xref: cpmsftngxa10.phx.gbl
microsoft.public.dotnet.framework.compactframework:67657
X-Tomcat-NG: microsoft.public.dotnet.framework.compactframework

I tried This:

dsLibros.ReadXml("\Program Files\iPAQ\libros.xml")

Now it doesn't show any error, but doesn't show any data in the
DataGrid.

Any help.

--
David Fúnez
Tegucigalpa, Honduras


I have a little APP for an iPAQ that runs Ok but it does not show
any
record, the problem is with the XML File as shown.

The APP is a DataGrid and two Buttons, one to save data an one to
exit
the
App.

So, any help will be wellcome.

**** The Code *****
Dim dsLibros As DataSet
Dim dtPrestados As DataTable
Dim xmlFile As String = "Libros.xml"

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e
As
System.EventArgs) Handles MyBase.Load
dtPrestados = New DataTable("prestados")
dtPrestados.Columns.Add("Id", GetType(Integer))
dtPrestados.Columns.Add("Titulo", GetType(String))
dtPrestados.Columns.Add("prestadosA", GetType(String))
dtPrestados.Columns.Add("Fecha", GetType(Date))
dtPrestados.Columns.Add("Devuelto", GetType(Boolean))

With dtPrestados.Columns("id")
.AutoIncrement = True
.AutoIncrementSeed = 1
End With

dsLibros = New DataSet("Libros")
dsLibros.Tables.Add(dtPrestados)

dgLibros.DataSource = dsLibros.Tables(0) ' that's Ok, it
shows
the
columns

******* Mi problem is here, if i use this routine:

If File.Exists(xmlFile) Then
dsLibros.ReadXml(xmlFile)
Else
MsgBox("File doesn't exists")
End If

******* shows the File doesn't exists Message,

******* if i put this line: dsLibros.ReadXml(xmlFile) **** out
of
the
routine like this

*** dgLibros.DataSource = dsLibros.Tables(0)
*** dsLibros.ReadXml(xmlFile)

*** it lounches an error

End Sub

Private Sub btnExit_Click(ByVal sender As System.Object, ByVal
e
As
System.EventArgs) Handles btnExit.Click
Me.Close()
End Sub

Private Sub btnSave_Click(ByVal sender As System.Object, ByVal
e
As
System.EventArgs) Handles btnSave.Click
dsLibros.WriteXml(xmlFile)
End Sub
 
I

Ilya Tumanov [MS]

So, it did not work before because no data was loaded. Most likely, the
schema created programmatically did not match XML file.

To add, delete or edit data in the grid you should work with a data source
grid is bound to.
In this case that would be table's default DataView: DataTable.DefaultView

You can use DataView's methods to add (DataView.AddNew()), delete
(DataView.Delete(row)) or modify (DataView[row][column]) rows.

To check which row is selected in the grid, use DataGrid.CurrentRowIndex.
It will match row index in the DataView bound to a grid.
However, it might NOT match row index in a DataTable, so you should not
work with table directly.

As for UI, the common practice is to pop up a new form (or use tabbed
interface) to allow row editing.
You can use buttons/menus to add/delete rows.

Best regards,

Ilya

This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
Reply-To: "David Fúnez" <[email protected]>
From: "David Fúnez" <[email protected]>
References: <[email protected]>
<[email protected]>
<[email protected]>
<[email protected]>
<[email protected]>
 
D

David Fúnez

Ilya;

Thanks a lot for your help and patience .... i will do what you say......


--
David Fúnez
Tegucigalpa, Honduras


"Ilya Tumanov [MS]" said:
So, it did not work before because no data was loaded. Most likely, the
schema created programmatically did not match XML file.

To add, delete or edit data in the grid you should work with a data source
grid is bound to.
In this case that would be table's default DataView: DataTable.DefaultView

You can use DataView's methods to add (DataView.AddNew()), delete
(DataView.Delete(row)) or modify (DataView[row][column]) rows.

To check which row is selected in the grid, use DataGrid.CurrentRowIndex.
It will match row index in the DataView bound to a grid.
However, it might NOT match row index in a DataTable, so you should not
work with table directly.

As for UI, the common practice is to pop up a new form (or use tabbed
interface) to allow row editing.
You can use buttons/menus to add/delete rows.

Best regards,

Ilya

This posting is provided "AS IS" with no warranties, and confers no
rights.

--------------------
Reply-To: "David Fúnez" <[email protected]>
From: "David Fúnez" <[email protected]>
References: <[email protected]>
<[email protected]>
<[email protected]>
<[email protected]>
<[email protected]>
 

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