Share Pastebin
Guest
Private paste!

Untitled

By: a guest | Apr 15th, 2010 | Syntax: VB.NET | Size: 1.01 KB | Hits: 300 | 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 SQLStr As String
  8.         Dim ConnString As String
  9.  
  10.         'Connstring = Server Name, Database Name, Windows Authentication
  11.         ConnString = "Data Source=MATHEW-PC\SQLEXPRESS;Initial Catalog=Test;Integrated Security=True"
  12.  
  13.         SQLStr = "UPDATE RSSFEEDS SET Name = 'Google Snooze' Where RSSID = 1"
  14.  
  15.         'Write to SQL
  16.  
  17.         Dim SQLConn As New SqlConnection() 'The SQL Connection
  18.         Dim SQLCmd As New SqlCommand() 'The SQL Command
  19.  
  20.         SQLConn.ConnectionString = ConnString 'Set the Connection String
  21.         SQLConn.Open() 'Open the connection
  22.  
  23.         SQLCmd.Connection = SQLConn 'Sets the Connection to use with the SQL Command
  24.         SQLCmd.CommandText = SQLStr 'Sets the SQL String
  25.         SQLCmd.ExecuteNonQuery() 'Executes SQL Commands Non-Querys only
  26.  
  27.         SQLConn.Close() 'Close the connection  
  28.         SQLConn.Dispose()
  29.  
  30.         Console.ReadLine()
  31.  
  32.     End Sub
  33. End Module