' Collection of code snippets by Arne Vajhøj 
' (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
Imports System
Imports System.IO
Imports System.Data
Imports System.Data.SqlClient

Class MainClass
    Public Shared Sub Main(ByVal args As String())
        Dim con As SqlConnection = New SqlConnection ("server=ARNEPC3;Integrated Security=SSPI;database=Test")
        con.Open
        Dim cre As SqlCommand = New SqlCommand ("CREATE TABLE guidtest (id UNIQUEIDENTIFIER PRIMARY KEY,data VARCHAR(50))", con)
        cre.ExecuteNonQuery
        Dim ins As SqlCommand = New SqlCommand ("INSERT INTO guidtest VALUES(NEWID(), 'bla bla')", con)
        ins.ExecuteNonQuery
        Dim sel As SqlCommand = New SqlCommand ("SELECT * FROM guidtest", con)
        Dim rdr As SqlDataReader = sel.ExecuteReader
        While rdr.Read
            Dim id As Guid = CType(rdr(0), Guid)
            Dim data As String = CType(rdr(1), String)
            Console.WriteLine(id.ToString & " " & data)
        End While
        rdr.Close
        Dim drp As SqlCommand = New SqlCommand("DROP TABLE guidtest", con)
        drp.ExecuteNonQuery
        con.Close
    End Sub
End Class 
