01.
Option
Explicit
On
02.
Option
Strict
On
03.
Imports
System.Data
04.
Imports
System.Data.SqlClient
05.
Imports
MySql.Data.MySqlClient
06.
07.
Friend
Class
connectionDB
08.
09.
Public
connectionSQL
As
MySqlConnection
10.
Public
commandSQL
As
MySqlCommand
11.
Public
readerSQL
As
MySqlDataAdapter
12.
13.
Public
Sub
connectMySQL()
14.
Try
15.
connectionSQL =
New
MySqlConnection
16.
connectionSQL.ConnectionString =
"Data Source=localhost;Initial Catalog=Inventory;User ID=sa;Password=30082531"
17.
If
connectionSQL.State = ConnectionState.Closed
Then
18.
connectionSQL.Open()
19.
End
If
20.
21.
Catch
ex
As
Exception
22.
MsgBox(ex.Message)
23.
End
Try
24.
End
Sub
25.
26.
Public
Sub
closeSQL()
27.
Try
28.
connectionSQL.Close()
29.
commandSQL.Cancel()
30.
connectionSQL =
Nothing
31.
commandSQL =
Nothing
32.
readerSQL =
Nothing
33.
Catch
ex
As
Exception
34.
35.
End
Try
36.
37.
End
Sub
38.
39.
End
Class