troubleshooting Question

VB.NET connection to MySQL

Avatar of mike_F1
mike_F1 asked on
8 Comments1 Solution442 ViewsLast Modified:
Having worked with JET and Access my entire life!, I have finally decided to take a look at SQL - in particular MySQL Sever version 4.1, MySQL Connector Net 1.0 (Net 1.1 , Visual Basic 2003).

Many examples I have seen have used ODBC to connect but I am currently looking at using the .NET reference provided with MySQL - perhaps some-one can tell me the Pros and Cons of these two methods - but that's an aside really.

My current problem is that this code simply does not connect.  On the con.Open() command I get the exception: "specified cast is not valid."

Here's the code:

Imports MySql.Data.MySqlClient
Sub Main()
        Dim Con As New MySqlConnection
        Dim cmd As MySqlCommand

        Con.ConnectionString = "server=localhost;database=smrs;uid=root;"
        Catch ex As Exception
            MsgBox("Can't open the database" & vbCr & ex.Message, MsgBoxStyle.Critical, "Error!")
            Exit Sub
        End Try

Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 8 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 8 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros