Log in

I forgot my password

Alumni of BSU INFORMATION TECHNOLOGY

BSU INFO-TECH

FB COMMENT

VB.net+mysql connection string

View previous topic View next topic Go down

VB.net+mysql connection string

Post by Generym on Tue 27 Dec 2011, 3:12 am

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



Generym
Admin
Admin

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

View user profile http://bsu-infotech.forumotion.com

Back to top Go down

Re: VB.net+mysql connection string

Post by markjeggar on Wed 11 Apr 2012, 7:51 pm

a simple connection string program in vb.net

http://vb.net-informations.com/ado.net/connectionstring.htm



jgr.

markjeggar
Private
Private

Male
Number of posts: 1
Age: 34
Location: india
Job/hobbies: never
Reputation: 0
Registration date: 2012-04-11

View user profile

Back to top Go down

View previous topic View next topic Back to top

- Similar topics

Permissions in this forum:
You cannot reply to topics in this forum