

I have two server running, so I used the port number to connect to the specific one.

user id: The user of the mysql database server.Data Source: We have our database in our local machine, thus I have used “localhost”, if you have your DB at some other computer connected by LAN to your machine, you will put the IP address of that machine instead of localhost.Here, look at the connection string which as currently have 5 parts as follows
Visual studio 2010 automatic password generator code#
The code looks like the following dbconn = New MySqlConnection("Data Source=localhost user id=root password=demo port=3310 database=vb_mysql") Try dbconn.Open() Catch ex As Exception MsgBox("Connection Error: " & ex.Message.ToString) End Try We will open the connection to the DB in the load event of our form which now named as form1 by default. Okay, now we are going to make the connection. dbread is the one which will hold those data that we will fetch using query from DB.dbcomm is the MySqlCommand that will execute the query.sql is a string, which will actually hold our query.dbconn is the connection to the database.Here we are declaring 4 public objects that we will use. Now, just below Public Class Form1 write the followings Public dbconn As New MySqlConnection Public sql As String Public dbcomm As New MySqlCommand Public dbread As MySqlDataReader This will allow us to use various types, methods and classes of the Connector. Now Double-Click on the form to bring the code editor.Ībove everything, write this Imports We are done with the database and form so far, lets start coding in the next part.
