Guest User

Untitled

a guest
Apr 15th, 2010
325
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 1.01 KB | None | 0 0
  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 = "INSERT into RSSFEEDS(URL, Name) VALUES('http://news.google.com', 'Google News')"
  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.  
  29.         Console.ReadLine()
  30.  
  31.     End Sub
  32. End Module
Advertisement
Add Comment
Please, Sign In to add comment