01.
Imports
MySql.Data.MySqlClient
02.
03.
Module
ModuleCode
04.
Friend
FileConfigINI_mcode = Application.StartupPath +
"\CONFIG.ini"
05.
Friend
server
As
String
= HexToStr(ReadIni(FileConfigINI_mcode,
"database_config"
,
"server"
,
""
))
06.
Friend
database
As
String
= HexToStr(ReadIni(FileConfigINI_mcode,
"database_config"
,
"data_base_name"
,
""
))
07.
Friend
user
As
String
= HexToStr(ReadIni(FileConfigINI_mcode,
"database_config"
,
"data_base_user"
,
""
))
08.
Friend
password
As
String
= HexToStr(ReadIni(FileConfigINI_mcode,
"database_config"
,
"data_base_password"
,
""
))
09.
Friend
port
As
String
= HexToStr(ReadIni(FileConfigINI_mcode,
"database_config"
,
"data_base_port"
,
""
))
10.
11.
Public
data
As
String
=
"Server='"
& server &
"';Port='"
& port &
"';Database='"
& database &
"';Uid='"
& user &
"';Pwd='"
& password &
"';Convert Zero Datetime=True;"
12.
13.
14.
15.
16.
17.
Public
ConnectionDB
As
New
MySqlConnection(data)
18.
Dim
constrAppconfig
As
String
=
"server="
+ server +
";Port="
+ port +
";user id="
+ user +
";password="
+ password +
";database="
+ database +
";Convert Zero Datetime=True;"
19.
20.
21.
22.
23.
24.
Public
strSQL
As
String
25.
26.
27.
28.
29.
30.
Public
dtAdapter
As
MySqlDataAdapter
31.
32.
33.
34.
35.
36.
Public
dt
As
DataTable
37.
38.
39.
40.
41.
42.
Public
ds
As
DataSet
43.
44.
45.
46.
47.
48.
Public
dRow
As
DataRow
49.
50.
51.
52.
53.
54.
Public
cmd
As
MySqlCommand
55.
56.
57.
58.
59.
60.
Public
Dr
As
MySqlDataReader
61.
62.
63.
64.
65.
66.
Public
dv
As
DataView
67.
Public
saveMess
As
Integer
68.
Friend
cashSelectDetail
As
String
69.
70.
71.
72.
73.
74.
Public
Sub
open_connection()
75.
Try
76.
If
ConnectionDB.State = ConnectionState.Open
Then
ConnectionDB.Close()
77.
ConnectionDB.Open()
78.
Catch
ex
As
Exception
79.
Throw
New
Exception(
"การเชื่อมต่อฐานข้อมูลใช้งานไม่ได้ เกิดข้อผิดพลาด : "
& ex.Message)
80.
End
Try
81.
End
Sub
82.
End
Module