Guest
Private paste!

Untitled

By: a guest | Apr 16th, 2010 | Syntax: VB.NET | Size: 1.46 KB | Hits: 160 | Expires: Never
Copy text to clipboard
  1. Imports System.Data.SqlClient
  2.  
  3. Module Module1
  4.  
  5.     Sub Main(ByVal sArgs() As String)
  6.  
  7.         Dim ConnString As String
  8.  
  9.         'Connstring = Server Name, Database Name, Windows Authentication
  10.         ConnString = "Data Source=MATHEW-PC\SQLEXPRESS;Initial Catalog=Test;Integrated Security=True"
  11.  
  12.         'Write to SQL
  13.  
  14.         Dim SQLConn As New SqlConnection() 'The SQL Connection
  15.         Dim SQLCmd As New SqlCommand() 'The SQL Command
  16.  
  17.         SQLConn.ConnectionString = ConnString 'Set the Connection String
  18.         SQLConn.Open() 'Open the connection
  19.  
  20.         Try
  21.             SQLCmd = New SqlCommand("sps_rssfeeds_getall", SQLConn)
  22.             SQLCmd.CommandType = CommandType.StoredProcedure
  23.  
  24.             Dim SQLdr As SqlDataReader = SQLCmd.ExecuteReader()
  25.  
  26.             While SQLdr.Read()
  27.                 Dim iRSSID As Integer = SQLdr.GetInt32(SQLdr.GetOrdinal("RSSID"))
  28.                 Dim sURL As String = SQLdr.GetString(SQLdr.GetOrdinal("Url"))
  29.                 Dim sName As String = SQLdr.GetString(SQLdr.GetOrdinal("Name"))
  30.  
  31.                 Console.WriteLine("RSSID: {0}", iRSSID)
  32.                 Console.WriteLine("  URL: {0}", sURL)
  33.                 Console.WriteLine(" Name: {0}", sName)
  34.             End While
  35.  
  36.         Catch ex As Exception
  37.             Console.WriteLine(ex.Message)
  38.             Throw
  39.         Finally
  40.             SQLConn.Close()
  41.             SQLConn.Dispose()
  42.         End Try
  43.  
  44.         Console.ReadLine()
  45.     End Sub
  46. End Module