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
VB.NET Sql Select Statement Source Code Example
Description:
Illustrates using Sql Select Statement and writing to an output table.
Example Class:
Imports System Imports System.Data Imports System.Data.SqlClient Public Class clsSQLSelect Shared WithEvents con As SqlConnection Sub Main() con = New SqlConnection("Server=(local)\SQLEXPRESS;Initial Catalog=Northwind;Integrated Security=SSPI") ' Create the command object Dim str As String = "SELECT EmployeeID, FirstName, LastName FROM Employees" Dim cmd As New SqlCommand(str, con) Dim da As New SqlDataAdapter(cmd) Dim ds As New DataSet() da.Fill(ds, "Employees") Dim dc As DataColumn For Each dc In ds.Tables(0).Columns Console.Write("{0,15}", dc.ColumnName) Next Console.Write(vbCrLf) Dim dr As DataRow For Each dr In ds.Tables(0).Rows Dim i As Integer For i = 1 To ds.Tables(0).Columns.Count Console.Write("{0,15}", dr(i - 1)) Next i Console.Write(vbCrLf) Next Console.ReadLine() End Sub End Class
Example Module:
Module Module1 Sub Main() '***** DataBaseADONET ************* Dim mySQLSelect As New clsSQLSelect mySQLSelect.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