Home All Groups Group Topic Archive Search About
Author
29 Mar 2006 2:43 PM
Darin
I can get an XML loaded into a datagrid using:

Dim ds As New DataSet
ds.ReadXml("jp.xml")
gData.DataSource = ds

But, this a grid that allows clicking on the plus to see styles,
alignment, etc.

I want to load it in a datagrid so it appears in rows and columns just
like if I were to load a CSV file using:

Dim tmpConnection As New
System.Data.OleDb.OleDbConnection(DDIConnectString("test.csv"))
tmpConnection.Open()

strsql = "SELECT  * FROM test.csv"
Dim da As New System.Data.OleDb.OleDbDataAdapter(strsql, tmpConnection)
Dim ds As New DataSet("Workbook")
Dim dt As DataTable
Dim drRow As DataRow

da.Fill(ds, "Sheet1")
dt = ds.Tables("Sheet1")
gData.DataSource = dt
tmpConnection.Close()

Thanks.

Darin

*** Sent via Developersdex http://www.developersdex.com ***

Author
29 Mar 2006 5:12 PM
Chris
Darin wrote:
Show quoteHide quote
> I can get an XML loaded into a datagrid using:
>
> Dim ds As New DataSet
> ds.ReadXml("jp.xml")
> gData.DataSource = ds
>
> But, this a grid that allows clicking on the plus to see styles,
> alignment, etc.
>
> I want to load it in a datagrid so it appears in rows and columns just
> like if I were to load a CSV file using:
>
> Dim tmpConnection As New
> System.Data.OleDb.OleDbConnection(DDIConnectString("test.csv"))
> tmpConnection.Open()
>
> strsql = "SELECT  * FROM test.csv"
> Dim da As New System.Data.OleDb.OleDbDataAdapter(strsql, tmpConnection)
> Dim ds As New DataSet("Workbook")
> Dim dt As DataTable
> Dim drRow As DataRow
>
> da.Fill(ds, "Sheet1")
> dt = ds.Tables("Sheet1")
> gData.DataSource = dt
> tmpConnection.Close()
>
> Thanks.
>
> Darin
>
> *** Sent via Developersdex http://www.developersdex.com ***


You have the answer to your problem in your code.

In the first one you assign a DataSet to the datagrid
ds.ReadXml("jp.xml")
gData.DataSource = ds

In the second one you assign a DataTable to the datagrid
da.Fill(ds, "Sheet1")
dt = ds.Tables("Sheet1")

So if you assign the DataTable that is in the dataset, you will get the
result you are looking for.

Chris
Author
29 Mar 2006 6:29 PM
Darin
What about the dataadaptor part, which then has the da.fill(ds,"Sheet")?

Darin

*** Sent via Developersdex http://www.developersdex.com ***
Author
29 Mar 2006 7:51 PM
Chris
Chris wrote:
Show quoteHide quote
> Darin wrote:
>
>> I can get an XML loaded into a datagrid using:
>>
>> Dim ds As New DataSet
>> ds.ReadXml("jp.xml")
>> gData.DataSource = ds
>>
>> But, this a grid that allows clicking on the plus to see styles,
>> alignment, etc.
>>
>> I want to load it in a datagrid so it appears in rows and columns just
>> like if I were to load a CSV file using:
>>
>> Dim tmpConnection As New
>> System.Data.OleDb.OleDbConnection(DDIConnectString("test.csv"))
>> tmpConnection.Open()
>>
>> strsql = "SELECT  * FROM test.csv"
>> Dim da As New System.Data.OleDb.OleDbDataAdapter(strsql, tmpConnection)
>> Dim ds As New DataSet("Workbook")
>> Dim dt As DataTable
>> Dim drRow As DataRow
>>
>> da.Fill(ds, "Sheet1")
>> dt = ds.Tables("Sheet1")
>> gData.DataSource = dt
>> tmpConnection.Close()
>>
>> Thanks.
>>
>> Darin
>>
>> *** Sent via Developersdex http://www.developersdex.com ***
>
>
>
> You have the answer to your problem in your code.
>
> In the first one you assign a DataSet to the datagrid
> ds.ReadXml("jp.xml")
> gData.DataSource = ds
>
> In the second one you assign a DataTable to the datagrid
> da.Fill(ds, "Sheet1")
> dt = ds.Tables("Sheet1")
>
> So if you assign the DataTable that is in the dataset, you will get the
> result you are looking for.
>
> Chris

That is just loading your DataSet.  The ds.ReadXml does it in your first
example.  Just bind the DataSet.Table(0) to your datagrid, you should be
good.

Chris