Imports System Imports System.Data Imports System.Data.SqlClient Imports System.Xml Module DBSchema Sub Main() ' Create the data adapter object pointing to the authors table ' creazione di un dataset che apre solo lo schema di una tabella ' SQL nel Database PUBS - tabella AUTHORS, legge un file XML ' e vengono visualizzati Nome campi e dati Dim da As New SqlDataAdapter( _ "SELECT au_id, au_lname, au_fname, phone FROM authors", _ "server=(local);database=pubs;integrated security=sspi") Dim ds As New DataSet("Authors") da.FillSchema(ds, SchemaType.Source) ds.ReadXml("..\SampleData.xml") Dim Table As DataTable = ds.Tables(0) Dim numCols As Integer = Table.Columns.Count Dim Row As DataRow For Each Row In Table.Rows Dim i As Integer For i = 0 To numCols - 1 Console.WriteLine(Table.Columns(i).ColumnName & " = " & Row(i)) Next Console.WriteLine() Next Console.ReadLine() End Sub End Module |