Untitled
By: a guest | Apr 16th, 2010 | Syntax:
VB.NET | Size: 1.46 KB | Hits: 160 | Expires: Never
Imports System.Data.SqlClient
Module Module1
Sub Main(ByVal sArgs() 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"
'Write to SQL
Dim SQLConn As New SqlConnection() 'The SQL Connection
Dim SQLCmd As New SqlCommand() 'The SQL Command
SQLConn.ConnectionString = ConnString 'Set the Connection String
SQLConn.Open() 'Open the connection
Try
SQLCmd = New SqlCommand("sps_rssfeeds_getall", SQLConn)
SQLCmd.CommandType = CommandType.StoredProcedure
Dim SQLdr As SqlDataReader = SQLCmd.ExecuteReader()
While SQLdr.Read()
Dim iRSSID As Integer = SQLdr.GetInt32(SQLdr.GetOrdinal("RSSID"))
Dim sURL As String = SQLdr.GetString(SQLdr.GetOrdinal("Url"))
Dim sName As String = SQLdr.GetString(SQLdr.GetOrdinal("Name"))
Console.WriteLine("RSSID: {0}", iRSSID)
Console.WriteLine(" URL: {0}", sURL)
Console.WriteLine(" Name: {0}", sName)
End While
Catch ex As Exception
Console.WriteLine(ex.Message)
Throw
Finally
SQLConn.Close()
SQLConn.Dispose()
End Try
Console.ReadLine()
End Sub
End Module