Erm's I.T. Girl – Zelna Ellis

Don't fear when Zel is near…

10 Husbands

A lawyer married a woman who had previously divorced ten husbands.On their wedding night, she told her new husband, “Please be gentle; I’m still a virgin.

“What?” said the puzzled groom. “How can that be if you’ve been married ten times?”

“Well, husband #1 was a Sales Representative; he kept telling me how great it was going to be.

Husband #2 was in Software Services; he was never really sure how it was supposed to function, but he said he’d look into it and get back to me.

Husband #3 was from Field Services; he said everything checked out diagnostically but he just couldn’t get the system up.

Husband #4 was in Telemarketing; even though he knew he had the order, didn’t know when he would be able to deliver.

Husband #5 was an Engineer; he understood the basic process but wanted three years to research, implement, and design a new state-of-the-art method.

Husband #6 was from Finance and Administration; he thought he knew how, but he wasn’t sure whether it was his job or not.

Husband #7 was in Marketing; although he had a product, he was never sure how to position it.

Husband #8 was a psychiatrist; all he ever did was talk about it.

Husband #9 was a gynecologist; all he did was look at it.

Husband #10 was a stamp collector; all he ever did was … God, I miss him!”

“But now that I’ve married you, I’m really excited!” “Good,” said the husband, “but, why?” “Duh; you’re a LAWYER. This time I KNOW I’m gonna get screwed!”

26 March 2009 Posted by zellis | Jokes | , , | No Comments Yet

.NET & MySQL Part 4

Setup MySQL Connection String for a Windows application using VB.NET

Software used in this post:

In Visual Studio

  • Create a Windows Form Application named TestConn.
    frmTest only has two buttons: btnTest and btnExit.
    Fig. 1
  • Add Reference
    From the menu select Project | Add Reference
    Scroll down, select MySQL.Data, and click OK.
    Fig. 2
  • The Program Code

    Imports MySql.Data.MySqlClient

    Public Class frmTest
      Dim MySQLConnectionString As String
      Dim MyADOConnection As MySqlConnection

     Private Sub btnTest_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnTest.Click
      Try
        MySQLConnectionString =     ”Server=hostname;” & _
        ”Database=mydbschema;” & _
        ”Uid=myusername;” & _
        ”Pwd=mypassword;” & _
        ”Connect Timeout=30;”

        MyADOConnection = New MySqlConnection()
        MyADOConnection.ConnectionString = MySQLConnectionString
        MyADOConnection.Open()
        MessageBox.Show(“Connection Opened Successfully!”, “Test Connection”)
      Catch ex As Exception
        MessageBox.Show(“Error Connecting to Database: ” & Err.Description, “Test Connection”))
      End Try
     End Sub

     Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click
      Try
        MyADOConnection.Close()
        MyADOConnection.Dispose()
      Catch ex As Exception
        ’Do Nothing
      End Try
      Application.Exit()
     End Sub
    End Class

  • Run the program
    Click the Test button. The following message should display if the connection was successful:
    Fig. 3
    Click the Exit button

Conclusion:
Read here more about the connection strings.

In this example the connection string was hardcoded (embedded). This is not recommended!

    Why?

  1. A malicious Connection String injection attack can occur. The injection attacker can completely destroy the database or retrieve important secure information.
  2. If any of the Connection String parameters change, the entire applications needs to be recompiled and redeployed again to all the computers.

:) Happy Coding

In the next post .NET & MySQL Part 5 we will have a look how to enable SSL for MySQL Server.

Previous Posts:
.NET & MySQL Part 1 A list of software required as well as optional software that can be used.
.NET & MySQL Part 2 Install MySQL Server
.NET & MySQL Part 3 Install PHP on Windows XP IIS Server

Version 1.1

26 March 2009 Posted by zellis | .NET & MySQL | , , , | No Comments Yet