What driver do you need to connect vb.net to MySQL?
How do I create a Data source to MySQL? ...am only getting the options for SQL and MS-database!

Please help... am designing a reg system for a college!
Thanx :-)

you'll need to import the following to use a SQL connection in VB.net

Imports System.Data 'Imports required to use SQL Connection
Imports System.Data.SqlClient 'Imports required to use SQL Connection

and here's some sample code for inserting a record into a SQL database in VB.net

Dim DBConn As New SqlConnection(MyModules.getConnectionString) 'Defines DBConn as a new SQL Connection, fetches Connection String from MyModules.getConnectionString() function
            Dim DBCmd As New SqlCommand 'Defines DBCmd as the SQL command which will be executed
            Dim DBAdap As New SqlDataAdapter 'Defines DBAdap as the SQL Data Adapter
            Dim DS As New DataSet 'Defines DS as the Data Set

            DBCmd = New SqlCommand("SET DATEFORMAT dmy;INSERT INTO tblExample(Field1, Field2, Field3, Field4, Field5, Field6, Field7) VALUES (@Field1, @Field2, @Field3, @Field4, @Field5, @Field6, @Field7)", DBConn) 'The Parameterized SQL command to Insert data into the database
            DBCmd.Parameters.AddWithValue("@Field1", Textbox1.Text)
            DBCmd.Parameters.AddWithValue("@Field2", Textbox2.Text) 'Sets the parameters for the Insert command
            DBCmd.Parameters.AddWithValue("@Field3", Textbox3.Text) ' "
            DBCmd.Parameters.AddWithValue("@Field4", Textbox4.Text) ' "
            DBCmd.Parameters.AddWithValue("@Field5", Textbox5.SelectedValue) ' "
            DBCmd.Parameters.AddWithValue("@Field6", CheckBox1.Checked) ' "
            DBCmd.Parameters.AddWithValue("@Field7", CheckBox2.Checked) ' "

            DBConn.Open() 'Opens the SQL Connection
            DBCmd.ExecuteNonQuery() 'Executes the Insert Query
            DBConn.Close() 'Closes the SQL Connection

Hope that helps

- Jordan

Is inserting into the SQL database the same as inserting into MySQL database???
Will I need to install any drivers??

Thanx alot JJ.

They're pretty much the same, you don't need to install drivers, just make sure you import System.Data and System.Data.SqlClient

If its MS Access however then you need different imports


- Jordan

Hello JJ,

The database that am using is MySQL... The version of VB is VISUAL BASIC 2008 EXPRESS EDITION.

Wat am currently trying to do is insert data grids on a form which requires a datasouce to MySQL database! Now thats where the problem comes in. Please advise... Thanx.

Let me try out what u've told me.. I'll get back to u!

Thank you for helping,
Kind regards Dan.

So you want to put a data grid on a form that retrieves it's data through a SQL Data Source?

Do you have the toolbox in VS2008 express? I use VS 2008 full at work so I have no experience with the express edition.

- Jordan

How can i get the setup for VS 2008 FULL?
I want to retrieve data thru MySQL or ODBC datasource.. Not SQL.
Yes, VS2008 Express has the toolbox..
What the difference btw the two??
Thanx Jordan.

You'll still need to run SQL queries to retrieve the data whichever data source you use and you'll have to pay for the full VS2008, unless you're a member of an educational institution that have Student editions.

Express generally has less features than the full VS2008 because as the name suggests, it's the Express edition, it's more compact and isnt really designed for major project work although its completely possible.

If you're using MySQL then use the SQL data source, you should find it in the toolbox, just drag it onto your page in design and go through the wizard, that will be the easiest option for you if your knowledge of VB.Net isn't very strong.

If you have anymore questions then feel free to ask away.

- Jordan

You'll still need to run SQL queries to retrieve the data whichever data source you use and you'll have to pay for the full VS2008, unless you're a member of an educational institution that have Student editions.

Express generally has less features than the full VS2008 because as the name suggests, it's the Express edition, it's more compact and isnt really designed for major project work although its completely possible.

If you're using MySQL then use the SQL data source, you should find it in the toolbox, just drag it onto your page in design and go through the wizard, that will be the easiest option for you if your knowledge of VB.Net isn't very strong.

If you have anymore questions then feel free to ask away.

- Jordan

Thanx for the info..
I think i'll send you my code you have a look & maybe advise me!
Wat do u think??

You can send it if you wish, i'll be happy to take a look

- Jordan

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.