/
aprogrammer
/
dotnet-docs
Обзор
Документация
Войти
/
aprogrammer
/
dotnet-docs
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
samples/snippets/visualbasic/VS_Snippets_ADO.NET/DataWorks SqlClient.HasRows/VB/source.vb
41 строка
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.SqlClient Module Module1 Sub Main() Dim s As String = GetConnectionString() Dim c As SqlConnection = New SqlConnection(s) HasRows(c) Console.ReadLine() End Sub ' <Snippet1> Private Sub HasRows(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() If reader.HasRows Then Do While reader.Read() Console.WriteLine(reader.GetInt32(0) _ & vbTab & reader.GetString(1)) Loop Else Console.WriteLine("No rows found.") End If reader.Close() End Using End Sub ' </Snippet1> Private Function GetConnectionString() As String Throw New NotImplementedException() End Function End Module