前端之家收集整理的这篇文章主要介绍了
VB.NET 通过MySQLDriverCS连接Mysql,
前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
- 通过https://sourceforge.net/projects/mysqldrivercs/下载MysqLDriverCS安装程序,安装到本地电脑上,(后续不需要每台电脑都安装此程序),找到安装位置中的dll文件夹,
- 在.net程序中引用上面文件夹中的MysqLDriverCS.dll文件,并在代码中导入,并把 MysqLDriverCS.dll, libMysqL.dll,libMysqL-4.0.dll拷贝到项目文件夹中
Imports MysqLDriverCS
3.
Try
Dim MysqL As String = "Location=10.*.*.*;User Id=root;Data Source=;Port=3306;Password="
Dim Connection As New MysqLConnection(MysqL)
Connection.Open()
Dim sql As String = "insert into technologydept_onlinemackey set mainboardID='123456',test_time=Now()"
Dim command As MysqLCommand = New MysqLCommand(sql,Connection)
command.ExecuteNonQuery()
command.Dispose()
Connection.Close()
MsgBox("OK")
Catch ex As Exception
MsgBox(ex.Message)
End Try