Progress Monitor for IdealProgrammer.com
Take Swift, Intelligent, Massive, Planned, Loving, Effective (S.I.M.P.L.E.) Action to Transform Self into Ideal
Skip Repetitive Navigational Links
Home
News
Presenters
Register
Contact
Categories
Titles
Converter
Code Samples
C# ASP.NET
C# Console
HTML
JavaScript
SQL Server
VB ASP.NET
VB Console
Please login
SqlDataReader Example
Description:
Illustrates using SqlDataReader to read sql table.
Example Class:
Imports System Imports System.Data Imports System.Data.SqlClient Public Class clsSqlDataReader Shared WithEvents con As SqlConnection Public Sub Main() con = New SqlConnection("Server=(local)\SQLEXPRESS;Initial Catalog=Northwind;Integrated Security=SSPI") Dim cmd As New SqlCommand() cmd.CommandText = "SELECT FirstName, LastName FROM Employees" cmd.Connection = con Try con.Open() Dim reader As SqlDataReader = cmd.ExecuteReader '(CommandBehavior.SingleRow) While reader.Read() Console.WriteLine("{0} - {1}", _ reader.GetString(0), reader.GetString(1)) End While reader.Close() Finally con.Close() End Try Console.ReadLine() End Sub End Class
Example Module:
Module Module1 Sub Main() '***** DataBaseADONET ************* Dim mySqlDataReader As New clsSqlDataReader mySqlDataReader.Main() End Sub End Module
Home
News
Presenters
Register
Contact
Categories
Titles
Converter
Code Samples
C# ASP.NET
C# Console
HTML
JavaScript
SQL Server
VB ASP.NET
VB Console