做地方的门户网站,网站主页模板图片,龙华做棋牌网站建设,网站用户体验方案1、安装 Connector/ODBC2、查看数据源名称『控制面板』- 『管理工具』- 『数据源(ODBC)』-『添加』3、连接数据库Dim Conn,ConnString创建数据库实例Set ConnCreateObject(ADODB.Connection)连接字符串ConnStringDriver{Mysql ODBC 5.2w Driver};DATABASEmys…1、安装 Connector/ODBC2、查看数据源名称『控制面板』- 『管理工具』- 『数据源(ODBC)』-『添加』3、连接数据库Dim Conn,ConnString创建数据库实例Set ConnCreateObject(ADODB.Connection)连接字符串ConnStringDriver{Mysql ODBC 5.2w Driver};DATABASEmysql;UIDroot;PWDroot;PORT3306;SERVERlocalhost;打开数据库连接Conn.Open ConnStringIf Conn.State0 ThenMsgbox 连接数据库成功ElseMsgbox连接数据库失败End If关闭数据库实例Conn.CloseSet Conn Nothing4、数据库查询实例Dim Conn,ConnString,strSQLString,strRecordset,i,sumSet ConnCreateObject(ADODB.Connection)ConnStringDriver{Mysql ODBC 5.2w Driver};DATABASEmysql;UIDroot;PWDroot;PORT3306;SERVERlocalhost;Conn.Open ConnStringIf Conn.State0 ThenCall Query()elseMsgbox 连接数据库失败End IfFunction Query()创建数据集实例Set strRecordset CreateObject(ADODB.Recordset)查询数据库strSQLString Select * from db1,1表示只读;1,3表示插入数据;2,3表示修改数据strRecordset.Open strSQLString,conn,1,1使游标指向第一个记录strRecordset.MoveFirstsumWhile Not strRecordset.EOFFor i0 to strRecordset.Fields.Count-1sumsum strRecordset(i) NextMsgbox sum vbCRLF使游标进入下一个strRecordset.MoveNextWend关闭数据集实例strRecordset.CloseSet strRecordsetNothingEnd Function关闭数据库实例Conn.CloseSet ConnNothing