Untitled
By: a guest | Apr 15th, 2010 | Syntax:
VB.NET | Size: 1.29 KB | Hits: 276 | Expires: Never
Imports System.Data.SqlClient
Module Module1
Sub Main(ByVal sArgs() As String)
Dim SQLStr As String
Dim ConnString As String
'Connstring = Server Name, Database Name, Windows Authentication
ConnString = "Data Source=MATHEW-PC\SQLEXPRESS;Initial Catalog=Test;Integrated Security=True"
SQLStr = "SELECT Name from RSSFEEDS"
'Write to SQL
Dim SQLConn As New SqlConnection() 'The SQL Connection
Dim SQLCmd As New SqlCommand() 'The SQL Command
Dim SQLdr As SqlDataReader 'The Local Data Store
SQLConn.ConnectionString = ConnString 'Set the Connection String
SQLConn.Open() 'Open the connection
SQLCmd.Connection = SQLConn 'Sets the Connection to use with the SQL Command
SQLCmd.CommandText = SQLStr 'Sets the SQL String
SQLdr = SQLCmd.ExecuteReader 'Gets Data
While SQLdr.Read() 'While Data is Present
Console.WriteLine(SQLdr("Name")) 'Show data in a Message Box
End While
'Loop While SQLdr.NextResult() 'Move to the Next Record
SQLdr.Close() 'Close the SQLDataReader
SQLConn.Close() 'Close the connection
SQLConn.Dispose()
Console.ReadLine()
End Sub
End Module