Search Search

#1 worldwide
FREE Coding Lessons

since 1996
   THE BEST WAY to learn ASP & Asp.net!
Advertise Here!
click for details
Credits Host:
DiscountASP.net
Server Admin:
The "Team"
Contact Info.
Charles M. Carroll

my Blog
[prev. Lesson]  DB: Access Scalability
     [next Lesson]  ADO: Paging Records

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:

Chaz Wish List
Tall Tip $5
Grande Tip $20
Venti Tip $39
Tip Jar Thanks
2004 Thanks
2005 Thanks
HUGE Tip -love site