Author Archives: Buck

The Ultimate C# / VB Scratchpad

LINQPad is a great tool for writing Linq queries but it also makes an excellent scratch pad for writing C# and VB bits. I am currently learning C# and I use it all the time to test out sample code.

linq

You can also see your code in IL, which has been an interesting exercise for me.

linqil

Oh and you can query SQL Server, Entity Framework, Odata, and other data stores with it. Check it out and download it from here

Grand Rapids Barcamp August 20 & 21

BarCamp is an ad-hoc gathering born from the desire for people to share and learn in an open environment. It is an intense event with discussions, demos, and interaction from attendees, usually centered around design & technology topics. Read more and register here.

Kalamazoo X Conference April 2010

The Kalamazoo X Conference 2010 will be held April 10, 2010.

The X Conference is a one-day software development conference hosted in beautiful Southwest Michigan. While there are many great technical conferences in the region, their focus tends toward new technologies and programming languages. The Kalamazoo X Conference intends to uniquely complement those conferences by enabling attendees to boost their process, design, and communication skills in the following areas:

  • Human interaction, including social, personal, and career development.
  • Interface and graphic design.
  • Development processes and best practices.
  • Requirements analysis, architecture, design, and modeling.

I went to this last year and it was one of the best conferences that I have ever attended. If you are even remotely interested in a career in technology I would recommend that you try and make it to this one.

Details here.

West Michigan SQL Server Users Group Meeting

Location: Blue Granite Corporate Offices (directions)  Also to be broadcast via Microsoft Live Meeting.  Call Information listed below if attending via Livemeeting. Date: Tuesday 1/26/2010 Time: 6:00pm – 8:00pm

  • 6:00pm – 6:30pm Welcome Mixer / Pizza / Beverages
  • 6:30pm – 6:45pm General Announcements / WMSSUG Business
  • 6:45pm – 7:45pm Presentation and Q&A
  • 7:45pm – 8:00pm Closing remarks / Giveaways

View Map here.

Windows “God” mode

SQL Dennis points out that Windows 7 as well as Vista has a god mode.

Basically you add a new folder to your desktop and name it GodMode.{ED7BA470-8E54-465E-825C-99712043E01C}. After that is done you will see a new icon on your desktop, which gives you access to most, if not all, Windows settings in one place.

See this for details and comments.

Create a CSV file from Dataset

First Declare a form level Dataset

Public Class frmCSV
    Dim ds As New DataSet

Next connect to your data source and build your dataset. In this case I am going to build one on the fly with this

Private Sub BuildDS()
     Dim dt As New DataTable
     Dim dr As DataRow
     Dim idColumn As DataColumn = _
         New DataColumn("ID", Type.GetType("System.Int32"))
     Dim FNColumn As DataColumn = _
         New DataColumn("FirstName", Type.GetType("System.String"))
     Dim LNColumn As DataColumn = _
         New DataColumn("LastName", Type.GetType("System.String"))

     dt.Columns.Add(idColumn)
     dt.Columns.Add(FNColumn)
     dt.Columns.Add(LNColumn)

     dr = dt.NewRow()
     dr("ID") = 1
     dr("FirstName") = "Randy"
     dr("LastName") = "Flag"
     dt.Rows.Add(dr)

     dr = dt.NewRow()
     dr("ID") = 2
     dr("FirstName") = "Tom"
     dr("LastName") = "Servo"
     dt.Rows.Add(dr)

     ds.Tables.Add(dt)

 End Sub

Now the code to loop trough your dataset and write the results to a file.

Private Sub WriteDS2CSV(ByVal ds As DataSet, ByVal FilePath As String)
    Dim str As New System.Text.StringBuilder
    For Each dr As DataRow In ds.Tables(0).Rows
        For Each field As Object In dr.ItemArray
            str.Append(field.ToString & ",")
        Next
        str.Replace(",", vbNewLine, str.Length - 1, 1)
    Next
    Try
        My.Computer.FileSystem.WriteAllText(FilePath, str.ToString, False)
        MessageBox.Show("File Created", "Success", MessageBoxButtons.OK)
    Catch ex As Exception
        MessageBox.Show(ex.Message, "Write Error", MessageBoxButtons.OK)
    End Try
End Sub

All that is left is to actually build the dataset and then pass it as well as the file name and path to the WriteDS2CSV sub.

 

Private Sub btnWriteCSV_Click( _
    ByVal sender As System.Object, _
    ByVal e As System.EventArgs) Handles btnWriteCSV.Click

    BuildDS()
    WriteDS2CSV(ds, "C:\dsExport.csv")

End Sub

A Function to extract the "name part" of an email

A handy little function to remove the name part of an email address.

Public Class Form1
    Public Function getNameFromEmail(ByVal strEmail As String) As String
        ' This purpose of this function is to return the
        ' name part of an email address. For instance
        ' joe@somewhere.com would return just joe.

        ' Use the IndexOf to find out how many characters
        ' in the @ sign is so I can use that number later
        ' to determine the amount of characters to select
        ' in the substring. 

        Dim i As Integer = strEmail.IndexOf("@")
        Dim newstring As String = strEmail.Substring(0, i)
        Return newstring
    End Function

    Private Sub Button1_Click( _
        ByVal sender As System.Object, _
        ByVal e As System.EventArgs) Handles Button1.Click

        Dim emailArray() As String = { _
            "me@somewhere.com", _
            "you@anywhere.com", _
            "them@nowhere.com"}

        For Each emailName As String In emailArray
            Dim strMess As String = CStr(getNameFromEmail(emailName))
            MessageBox.Show(strMess, "Email Name Test", _
            MessageBoxButtons.OK)
        Next
    End Sub
End Class

Photoshop for the iPhone

This a nice little application that allows you to edit iPhone photos on the fly. It includes a simple toolbar-style drop-down menu that lets you choose from a list of editing tools and effects. There is an option to set up an online account at Photoshop.com but it can be used with your own library of pictures.

Just search photoshop at the app store.

Real World Azure

Real World Azure presented by Dave Bost

What is the Windows Azure Platform? How can I take advantage of the Windows Azure Platform to scale my applications? We will answer these questions and more as we dive into the parts of the Windows Azure Platform and why it is the best cloud computing platform for .NET developers. We will discuss how to take advantage of Web and Worker roles to expose your application to your customers and to scale your computing power with a flip of a switch. We will also dive into the storage options found in the Windows Azure Platform including Table, Blob, Queues and the recently announced SQL Azure.

October 6th at the Michiana Area .net User Group. More information here.

Security Essentials

About Microsoft Security Essentials

Microsoft Security Essentials provides real-time protection for your home PC that guards against viruses, spyware, and other malicious software.

Microsoft Security Essentials is a free* download from Microsoft that is simple to install, easy to use, and always kept up to date so you can be assured your PC is protected by the latest technology. It’s easy to tell if your PC is secure — when you’re green, you’re good. It’s that simple.

Microsoft Security Essentials runs quietly and efficiently in the background so that you are free to use your Windows-based PC the way you want—without interruptions or long computer wait times.

It must be those Mac adds have really got to them. Find out more and down load here.