Log in
BSU INFO-TECH
FB COMMENT
VB.net+mysql connection string
Page 1 of 1 • Share •
VB.net+mysql connection string
Software needed
VB.NET
MySQL
MySQL Connector/Net 5.2
Create Connection
1.On Development PC, open Microsoft Visual Studio 2005.
2. Create a New Windows Application Project “SampleMySQL”.
3. First, I need to add a MySQL library. Right-click on the project name (SampleMySQL) -> Add Reference.
4. On Add Reference, select MySQL.Data on .NET tab.
5. By default, the reference library (MySQL.Data) won’t be copied to the output directory. That means when you deploy the application on other PC which doesn’t have the library installed, it’ll throw error. So I have to set the Copy Local property of the library file to True. Click Show All Files icon.
6. Expand References -> Select MySQL.Data -> Change Copy Local property to True.
7. Now it’s time to coding the application. First, I have to import a namespace. Open the Code View and add this line on the top.
Imports MySql.Data.MySqlClient
Private Sub Form1_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
TestConnection()
End Sub
Public Sub TestConnection()
Try
Dim connStr As String = "Database=world;" & _
"Data Source=192.168.125.21;" & _
"User Id=worldUser;Password=worldpassword"
Dim connection As New MySqlConnection(connStr)
connection.Open()
connection.Close()
MsgBox("Connection is okay.")
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
VB.NET
MySQL
MySQL Connector/Net 5.2
Create Connection
1.On Development PC, open Microsoft Visual Studio 2005.
2. Create a New Windows Application Project “SampleMySQL”.
3. First, I need to add a MySQL library. Right-click on the project name (SampleMySQL) -> Add Reference.
4. On Add Reference, select MySQL.Data on .NET tab.
5. By default, the reference library (MySQL.Data) won’t be copied to the output directory. That means when you deploy the application on other PC which doesn’t have the library installed, it’ll throw error. So I have to set the Copy Local property of the library file to True. Click Show All Files icon.
6. Expand References -> Select MySQL.Data -> Change Copy Local property to True.
7. Now it’s time to coding the application. First, I have to import a namespace. Open the Code View and add this line on the top.
Imports MySql.Data.MySqlClient
Private Sub Form1_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
TestConnection()
End Sub
Public Sub TestConnection()
Try
Dim connStr As String = "Database=world;" & _
"Data Source=192.168.125.21;" & _
"User Id=worldUser;Password=worldpassword"
Dim connection As New MySqlConnection(connStr)
connection.Open()
connection.Close()
MsgBox("Connection is okay.")
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub

Generym- Admin

-

Number of posts: 260
Reputation: 1
Registration date: 2008-11-12

Re: VB.net+mysql connection string
a simple connection string program in vb.net
http://vb.net-informations.com/ado.net/connectionstring.htm
jgr.
http://vb.net-informations.com/ado.net/connectionstring.htm
jgr.
markjeggar- Private

-

Number of posts: 1
Age: 32
Location: india
Job/hobbies: never
Reputation: 0
Registration date: 2012-04-11
Similar topics» [A-3362] Allow MySQL remote connection in Slackware
» [A-1838] QR Update 1.1.1, Octave 3.4.0, MySQL 5.0.92, MySQL 5.1.55
» [A-1118] MySQL Workbench 5.2.28 & libmpeg3 1.8
» [A-1415] MySQL Connector/ODBC 5.1.8
» Wifi Booster Cydia Tweak - Boost Wifi Connection On Your iPhone, iPod Touch & iPad
» [A-1838] QR Update 1.1.1, Octave 3.4.0, MySQL 5.0.92, MySQL 5.1.55
» [A-1118] MySQL Workbench 5.2.28 & libmpeg3 1.8
» [A-1415] MySQL Connector/ODBC 5.1.8
» Wifi Booster Cydia Tweak - Boost Wifi Connection On Your iPhone, iPod Touch & iPad
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum
» VB.net+mysql connection string
» pa visit nmn
» How to de-active your account here?
» Team Building
» Check attendance: name and batch, currently working at?
» I wonder!!!
» happy experience
» how smart is your smart phone?