Created
September 17, 2013 04:13
-
-
Save appforest/6590004 to your computer and use it in GitHub Desktop.
Getting data from SQL Server table using VB.Net (Based on http://msdn.microsoft.com/en-us/library/9kcbe65k.aspx?cs-save-lang=1&cs-lang=vb#code-snippet-2)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Imports System.Data.SqlClient | |
Public Class Form1 | |
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click | |
Using connection As New SqlConnection("Data Source=***SQL-SERVER-LOCATION***;Initial Catalog=***DB-NAME***;Integrated Security=True") | |
connection.Open() | |
Dim command As New SqlCommand("SELECT * FROM ***TABLE-NAME***", connection) | |
Dim reader As SqlDataReader = command.ExecuteReader() | |
While reader.Read() | |
Console.WriteLine("{0}", reader(0) & reader(1) & reader(2)) ''Depending on number of rows | |
End While | |
End Using | |
End Sub | |
End Class |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment