Loop through dataTable to store it in datagridview

  • Thread starter Thread starter dianas28
  • Start date Start date
D

dianas28

Guest
Good evening, I already have my DataTable structured as follows

.DataType = System.Type.GetType("System.String")
.AllowDBNull = False
.Caption = "Cédula jurídica"
.ColumnName = "CedulaJuridica"
_tablaClientes.Columns.Add(columna)

'Razon Social
columna = New DataColumn
.DataType = System.Type.GetType("System.Int32")
.AllowDBNull = False
.Caption = "Razón social"
.ColumnName = "RazonSocial"
_tablaClientes.Columns.Add(columna)

'Direccion
columna = New DataColumn
.DataType = System.Type.GetType("System.String")
.AllowDBNull = False
.Caption = "Dirrecion"
.ColumnName = "Direccion"
_tablaClientes.Columns.Add(columna)

Now as I go through it so that I can go through it, and at the end show it in a datagridview can you help me please. I have the following I am new to programming, but I try to do my best.

Public Sub llenarCliente()
Dim archivoXML As XmlDocument
Dim nodeLista As XmlNodeList
Dim node As XmlNode
Dim arregloClientes() As String
objetoEstructura.llenarDataTable()
Try
archivoXML = New XmlDocument
archivoXML.Load(Application.StartupPath & "\Empresas.xml")
nodeLista = archivoXML.SelectNodes("/Empresas/Empresa")
Dim fila As DataRow
For Each node In nodeLista
fila = objetoEstructura.tablaClientesP.NewRow
fila("CedulaJuridica") = arregloClientes(0)
fila("RazonSocial") = arregloClientes(1)
fila("Direccion") = arregloClientes(2)
fila("Provincia") = arregloClientes(3)
fila("Canton") = arregloClientes(4)
fila("Telefono") = arregloClientes(5)

objetoEstructura.tablaClientesP.Rows.Add(fila)
objetoEstructura.tablaClientesP.AcceptChanges()
Next
dgvClientesFactura.DataSource = objetoEstructura.tablaClientesP
Catch ex As Exception

End Try
End Sub

Continue reading...
 
Back
Top