The
ProgrammingMSAccess.COM Site
This sub procedure
Creates a Dataset with a dataTable and then prints the schema information
showing the name of the datatable and the name of the first column in the
datatable.
Private Sub Button2_Click( _
ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button2.Click
Dim cnn1 as SqlClient.SqlConnection
Dim strCnn1 As String
strCnn1 = "Data Source = (local); " & _
"Initial Catalog = Northwind; " & _
"Integrated Security = SSPI"
cnn1 = New SqlClient.SqlConnection(strCnn1)
'Declare and instantiate a new dataset
Dim das1 As New DataSet
'Declare a couple of strings for a
'DataAdapter
Dim str1 As String = TextBox1.Text
Dim str2 As String = "SELECT * " & _
"FROM Customers " & _
"WHERE CustomerID = '" & str1 & "'"
Dim DACustomer As SqlClient.SqlDataAdapter = _
New SqlClient.SqlDataAdapter(str2, _
cnn1)
'Fill the das1 from DACustomer
DACustomer.Fill(das1, "Customers")
'Display the name of the DataTable
'within das1, and the name of the first
'column in the DataTable
Console.WriteLine(das1.Tables(0). _
TableName)
Console.WriteLine(das1.Tables(0). _
Columns(0).ColumnName)
End Sub
Learn more about VB.NET programming from either
Programming Microsoft SQL Server 2000 with
Microsoft Visual Basic .NET or
Programming Microsoft Visual Basic .NET for Microsoft Access Databases.
Copyright 2003 CAB, Inc. All rights reserved. Republication or redistribution
of CAB, Inc. content, including by framing or similar means, is expressly
prohibited without the prior written consent of CAB, Inc. CAB, Inc. shall not be
liable for any errors in the content, or for any actions taken in reliance
thereon.