- 通過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 mysql As String = "server=localhost;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)
Dim commandm As MySQLCommand = New MySQLCommand("set names gb2312", Connection)
commandm.ExecuteNonQuery()
commandm.Dispose()
'Dim mydata As MySQLDataReader
'mydata = command.ExecuteReaderEx
'While mydata.Read
' If mydata.HasRows Then
' MsgBox(mydata(0).ToString)
' Else
' MsgBox("no")
' End If
'End While
command.ExecuteNonQuery()
command.Dispose()
Connection.Close()
MsgBox("OK")
Catch ex As Exception
MsgBox(ex.Message)
End Try
vb.net 與mysql通信中文產生亂碼的問題
http://blog.csdn.net/michaelscofielddong/article/details/7750380
Dim commandm As MySQLCommand = New MySQLCommand("set names gb2312", Connection)
commandm.ExecuteNonQuery()