30 lines
1.6 KiB
Plaintext
30 lines
1.6 KiB
Plaintext
try(destroyDialog YeomaiDataBaseConnectionTest)catch()
|
|
try(dotNet.loadAssembly "C:\\Program Files (x86)\\MySQL\\MySQL Connector NET 8.2.0\\MySql.Data.dll")catch(messagebox("dll载入失败,插件无法使用"))
|
|
rollout YeomaiDataBaseConnectionTest "无标题" width:837 height:639
|
|
(
|
|
label 'lbl1' "服务器" pos:[100,100] width:53 height:13 align:#right
|
|
label 'lbl2' "数据库名" pos:[100,130] width:53 height:13 align:#right
|
|
label 'lbl3' "用户名" pos:[100,160] width:23 height:13 align:#right
|
|
label 'lbl4' "密码" pos:[100,190] width:23 height:13 align:#right
|
|
editText 'host' "" pos:[170,100] width:241 height:22 align:#left text:"81.71.134.168"
|
|
editText 'database' "" pos:[170,130] width:241 height:22 align:#left text:"admin"
|
|
editText 'user' "" pos:[170,160] width:241 height:22 align:#left text:"admin123"
|
|
editText 'password' "" pos:[170,190] width:241 height:22 align:#left text:"aiAtB23yajDj2Lpa"
|
|
button 'btn1' "连接数据库" pos:[170,240] width:84 height:23 align:#left
|
|
button 'btn2' "断开数据库" pos:[280,240] width:84 height:23 align:#left
|
|
|
|
on 'btn1' pressed do(
|
|
connectionString = "Database=" + database.text + ";Data Source=" + host.text + ";User Id=" + user.text + ";Password=" + password.text
|
|
DBConnection = dotNetObject "MySql.Data.MySqlClient.MySqlConnection"
|
|
DBConnection.ConnectionString = connectionString
|
|
DBConnection.open()
|
|
if DBConnection.state.value__ then messagebox("连接成功!") else messagebox("连接失败!")
|
|
)
|
|
|
|
on 'btn2' pressed do(
|
|
-- 关闭连接
|
|
if DBConnection.state.value__ then (DBConnection.close();messagebox("断开连接!"))
|
|
)
|
|
|
|
)
|
|
createDialog YeomaiDataBaseConnectionTest |