Log in
BSU INFO-TECH
FB COMMENT
VB.net+mysql connection string
2 posters
Page 1 of 1
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
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 : 43
Location : india
Job/hobbies : never
Reputation : 0
Registration date : 2012-04-11
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum
Fri 25 Jan 2013, 12:12 pm by remase
» VB.net+mysql connection string
Wed 11 Apr 2012, 12:51 pm by markjeggar
» pa visit nmn
Tue 03 Jan 2012, 1:37 am by Generym
» How to de-active your account here?
Tue 27 Dec 2011, 1:57 am by Generym
» Team Building
Sat 26 Nov 2011, 5:31 am by kate
» Check attendance: name and batch, currently working at?
Fri 09 Sep 2011, 4:35 am by kuratcha
» I wonder!!!
Fri 01 Jul 2011, 2:08 am by Generym
» happy experience
Sun 01 May 2011, 10:07 pm by i337
» how smart is your smart phone?
Sun 01 May 2011, 9:56 pm by i337