Full control of MDB Database without data source

Source: Internet
Author: User
<%
'In in USER CONSTANTS
'To just use a DSN, the format is shown on the next line:
'Const DSN_NAME = "DSN = ASP101email"
'Two other samples I used it with. Left in as syntax examples for DSN-less connections
'Const DSN_NAME = "DBQ = C: InetPubwwwrootasp101samplesdatabase. mdb; Driver = {Microsoft Access Driver (*. mdb)}; DriverId = 25"
'Const DSN_NAME = "DBQ = C: InetPubdatabasedonations. mdb; Driver = {Microsoft Access Driver (*. mdb)}; DriverId = 25"
Dim DSN_NAME
DSN_NAME = "DBQ =" & Server. MapPath ("db_dsn.mdb") & "; Driver = {Microsoft Access Driver (*. mdb)}; DriverId = 25 ;"
Const DSN_USER = "username"
Const DSN_PASS = "password"
'OK, I know these are poorly named constants, so sue me!
'This script can be used without actually setting up a DSN, so
'Dsn_name as well as the other two constants shoshould really be named
'Something more generic like CONNECTION_STRING, CONNECTION_USER, and
'Connection_pass, but I did it this way without really thinking about
'It and I'm too lazy to change it now. If it bothers you, you do it!
'End USER CONSTANTS
'In in SUBS & FUNCTIONS SECTION
Sub OpenConnection
Set objDC = Server. CreateObject ("ADODB. Connection ")
ObjDC. ConnectionTimeout = 15
ObjDC. CommandTimeout = 30
ObjDC. Open DSN_NAME, DSN_USER, DSN_PASS
End Sub
Sub OpenRecordset (sType)
Dim sSqlString 'as String-building area for SQL query
Dim sCritOperator 'as String-basically "=" or "LIKE"
Dim sCritDelimiter 'as String-parameter delimiter "", "'", or "#"
Set objRS = Server. CreateObject ("ADODB. Recordset ")
Select Case sType
Case "ListTables" 'open RS of the Tables in the DB
Set objRS = objDC. OpenSchema (adSchemaTables)
Case "ViewTable" 'open the Selected Table

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.