如何使用VB2010连接网络mysql数据库
展开全部
必须安装MYSQL的驱动才行,不管是VB还是c++都需要这个驱动。代码如下: Public Function exemysql(ByVal sql As String) As ADODB.Recordset sql = Trim$(sql) Set conn = New ADODB.Connection Set rs = New ADODB.Recordset conn.Open "Driver=MySQL ODBC 3.51 Driver;" & _ "Server=服务器地址;" & _ "Port=3306;" & _ "Database=数据库名;" & _ "Uid=用户名;" & _ "Pwd=密码" conn.DefaultDatabase = "数据库名" conn.CursorLocation = adUseClient Set rs.ActiveConnection = conn rs.LockType = adLockBatchOptimistic rs.CursorType = adOpenKeyset rs.Open sql Set exesql = rs Set rs = Nothing Set conn = Nothing End Function
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询