Friday, August 23, 2013

How do I open SQL Server Management Studio?

For SQL Server 2005, click Start -> Run then type sqlwb

This will open SQL Server Management Studio

Monday, August 12, 2013

VB.NET Generate a random string of numbers and letters

Private Sub btn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn.Click
        Dim s As String = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
        Dim r As New Random
        Dim sb As New StringBuilder
        For i As Integer = 1 To 4
            Dim idx As Integer = r.Next(0, 35)
            sb.Append(s.Substring(idx, 1))
        Next
        Label2.Text = sb.ToString
    End Sub

Friday, August 2, 2013

Delete files in directory older than 7 days

Dim directory As New IO.DirectoryInfo("C:\Documents and Settings\CLIENT4\My Documents\log\")
        For Each file As IO.FileInfo In directory.GetFiles
            If (Now - file.CreationTime).Days < 7 Then file.Delete()
        Next