private sub c_connect_click()
err = 0
on error resume next
dim wrkodbc as workspace
dim conpubs as connection
dim mydb as database, mytable as tabledef
dim i as integer, j as integer
dim connectstr as string
docmd.hourglass true
docmd.setwarnings false
set mydb = dbengine.workspaces(0).databases(0)
dim passdb as string, ww as integer
dim f as integer, g as integer
passdb="pass"
connectstr = "odbc;dsn=" & me.dsn & ";"
connectstr = connectstr & "uid=" & me.dbuser_id & ";"
connectstr = connectstr & "pwd=" & passdb & ";"
'connectstr = connectstr & "pwd=" & me.dbpass_id & ";"
set wrkodbc = createworkspace("newodbcworkspace", "", "", dbuseodbc)
set conpubs = wrkodbc.openconnection("sam_user", dbdrivernoprompt, , connectstr)
if err <> 0 then goto dbuser_sam_err
on error goto dbuser_conn_err
i = mydb.tabledefs.count 'tables count
for j = 0 to i - 1
set mytable = mydb.tabledefs(j)
if mytable.attributes = db_attachedodbc or mytable.attributes = db_attachedodbc + db_attachsavepwd then
mytable.connect = connectstr
mytable.refreshlink
end if
next
on error resume next
docmd.hourglass false
msgbox "数据表连接完成!", , "天鸣"
err = 0
exit sub
dbuser_sam_err:
docmd.hourglass false
msgbox "数据库用户,口令错误,重新登录!", , "天鸣"
err = 0
exit sub
dbuser_conn_err:
docmd.hourglass false
msgbox error$(err), 16, "天鸣"
err = 0
exit sub
end sub
Java Asp PHP .Net XML C/C++ CGI VB Jsp J2ee J2se J2me EJB Servlet Tomcat Resin Struts Weblogic Eclipse ANT GUI JMS Web servise IDEA Webphere Hibernate Spring Jboss Applet Swing Socket Javamail Perl Ajax P2P 安全 模式 框架 测试 开源 游戏
Windows XP Windows 2000 Windows 2003 Windows Me Windows 9.x Linux UNIX 注册表 操作系统 服务器 应用服务器