代码如下:
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
最简单的办法是:在VB里添加一个ADO部件,将其放到窗体中,然后右键选择属性,在其属性页的下面有个生成连接字符串的项,点击其后的按钮,然后一步步的来做(很简单的),然后连接字符串就会在那里生成,只要拷贝这个字符串,就可以用ADODB来连接了。。。欢迎分享,转载请注明来源:内存溢出
评论列表(0条)