|
Access Tips: Password Protected Data, Record
Count
by Michael Audet <audet@vectorcore.com>
Two issues plagued after reading various lessons at
LearnASP.com and working with Access databases:
- How to open a DSN-less connection with OLEDB, using a database
password
- How to count how many records are in the database:
(Note: Use DSN-Less connections
over DSN for performance reasons. Suggested that your hosting service turns
off READ on the directory so no one can download your database. You still
need RWXD on the database for ASP to work with the
database.)
Download a copy of http://www.learnasp.com/adovbs.inc
to run the next sample that shows how to connect to a database with a password
and how to count records. A detailed explanation of "why" this count
records and what the cursor types mean is at
http://www.learnasp.com/freebook/asp/dbcount.aspx.
<!--#include
virtual="/learn/learnheader.asp"-->
<%
Set
RS=Server.CreateObject("ADODB.Recordset") 'Connection string CONN = "PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA
SOURCE=d:\data\info.mdb;Jet OLEDB:Database
Password=ILoveASP;" 'SQL query SQL =
"SELECT * FROM userinfo" 'Cursor
Location RS.CursorLocation = adUseClient 'Execute RS.Open SQL, CONN, adOpenStatic,
adLockReadOnly 'Show response.write("[" &RS.RecordCount
&"]<br>") 'Clean
Up RS.Close set RS=nothing %>
This information was collected from:
|