<%
' begin 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:\inetpub\wwwroot\asp101\samples\database.mdb;driver={microsoft access driver (*.mdb)};driverid=25"
'const dsn_name = "dbq=c:\inetpub\database\donations.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 should 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
' begin 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