/
aprogrammer
/
dotnet-docs
Обзор
Документация
Войти
/
aprogrammer
/
dotnet-docs
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
samples/snippets/visualbasic/VS_Snippets_ADO.NET/DataWorks SqlClient.GetSchemaTable/VB/source.vb
45 строк
1 KB
Genevieve Warren
SFI - ROPC work - VB snippets part 1 (#42691)
24 сен 2024, 21:39
Не верифицирован
24 сен 2024, 21:39
7f6485e
Код
Авторство
О чём код?
Option Explicit On Option Strict On Imports System.Data Imports System.Data.SqlClient Module Module1 Sub Main() Dim s As String = GetConnectionString() Dim c As SqlConnection = New SqlConnection(s) GetSchemaInfo(c) Console.ReadLine() End Sub ' <Snippet1> Private Sub GetSchemaInfo(ByVal connection As SqlConnection) Using connection Dim command As SqlCommand = New SqlCommand( _ "SELECT CategoryID, CategoryName FROM Categories;", _ connection) connection.Open() Dim reader As SqlDataReader = command.ExecuteReader() Dim schemaTable As DataTable = reader.GetSchemaTable() Dim row As DataRow Dim column As DataColumn For Each row In schemaTable.Rows For Each column In schemaTable.Columns Console.WriteLine(String.Format("{0} = {1}", _ column.ColumnName, row(column))) Next Console.WriteLine() Next reader.Close() End Using End Sub ' </Snippet1> Private Function GetConnectionString() As String Throw New NotImplementedException() End Function End Module