Function connecttodatabase() As Boolean
On Error GoTo err_conn
Dim AccessPath As String
AccessPath = IIf(Right(App.Path, 1) = "\", App.Path & "ACCESS\kehu.mdb", App.Path & "\ACCESS\kehu.mdb")
conn.Open "provider=Microsoft.jet.OLEDB.4.0;data source=" & AccessPath & ";Jet OLEDB:Database PassWord="
'设置服务器名称,数据库名称,登录名(此时密码为空)
'conn.connectionstring = "dsn=rsgl;database=kehu;uid=sa;pwd="
'conn.connectionstring = "provider=msdasql;database=kehu;server=computer;uid=sa;pwd="
'conn.Open
connecttodatabase = True
Exit Function
err_conn:
connecttodatabase = False
End Function