Share Pastebin
Guest
Private paste!

Untitled

By: a guest | Apr 21st, 2010 | Syntax: VB.NET | Size: 1.15 KB | Hits: 148 | 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_delete", SQLConn)
  22.             SQLCmd.CommandType = CommandType.StoredProcedure
  23.  
  24.             Dim sampParm As SqlParameter = SQLCmd.Parameters.Add("@p_rssid", SqlDbType.Int)
  25.             sampParm.Value = 3
  26.  
  27.             SQLCmd.ExecuteNonQuery()
  28.  
  29.         Catch ex As Exception
  30.             Console.WriteLine(ex.Message)
  31.             Throw
  32.         Finally
  33.             SQLConn.Close()
  34.         End Try
  35.  
  36.         SQLConn.Close() 'Close the connection  
  37.         SQLConn.Dispose()
  38.  
  39.         Console.ReadLine()
  40.     End Sub
  41. End Module