和SQL数据库差不多的,下面是我用vb6.0连接本地mysql数据库的连接字符串
"driver={MySQL ODBC 3.51 Driver}server=127.0.0.1database=mysqluid=rootpwd=sasa"必须安装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欢迎分享,转载请注明来源:内存溢出
评论列表(0条)