Join the forum, it's quick and easy

Would you like to react to this message? Create an account in a few clicks or log in to continue.
Log in

I forgot my password

Alumni of BSU INFORMATION TECHNOLOGY

BSU INFO-TECH

FB COMMENT

VB.net+mysql connection string

2 posters

Go down

VB.net+mysql connection string Empty VB.net+mysql connection string

Post by Generym Tue 27 Dec 2011, 2: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
Generym
Admin
Admin

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

https://bsu-infotech.forumotion.com

Back to top Go down

VB.net+mysql connection string Empty Re: VB.net+mysql connection string

Post by markjeggar Wed 11 Apr 2012, 12: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 : 43
Location : india
Job/hobbies : never
Reputation : 0
Registration date : 2012-04-11

Back to top Go down

Back to top


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