|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
XML into datagridDim 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 *** Darin wrote:
Show quoteHide quote > I can get an XML loaded into a datagrid using: You have the answer to your problem in your code.> > 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 *** 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 What about the dataadaptor part, which then has the da.fill(ds,"Sheet")?
Darin *** Sent via Developersdex http://www.developersdex.com *** Chris wrote:
Show quoteHide quote > Darin wrote: That is just loading your DataSet. The ds.ReadXml does it in your first > >> 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 example. Just bind the DataSet.Table(0) to your datagrid, you should be good. Chris
MS's Excruciating Update Cycles
Datagrid with VB 2005 Translation of CreateFile dll in dot net My computer seems to be to slow to run VS2005 Late Binding Question large arrays and system.outofmemoryexception DataBinding and Combo Boxes Problems with TCP Listener Is it possible to use Field Names instead of Item(0) with Data Row using VB.Net 2005 ? Web Panel? |
|||||||||||||||||||||||