Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ASP Script can't 'open' access database 1

Status
Not open for further replies.

soozle

IS-IT--Management
Jun 5, 2001
69
NT 4 server SP6a, Front Page Extensions (98) IIS 4
Access 97 database with SystemDSN setup

Using ASP I can add records to the database but can't Open the database for updating.
The following script:-

Set Con = Server.CreateObject( "ADODB.Connection")
Con.Open "VisitorBook"
Set rs = Server.CreateObject ("ADODB.Recordset" )
rs.ActiveConnection = Con
rs.CursorType = 3
this line >> rs.Open = "SELECT * FROM VisitorBook WHERE RecordNumber = " & recnum

gives the error
Object doesn't support this property or method: 'Open'

I've just built this web server from scratch after ours died.. have I missed something obvious ?

TIA
Soozle
 
Try these conventions.

Read only, free moving recordset.
Code:
<%
dim rs
dim strSQL
Set rs = Server.CreateObject (&quot;ADODB.Recordset&quot; )
rs.CursorType = 3
rs.CursorLocation = 3
strSQL = &quot;SELECT * FROM VisitorBook WHERE RecordNumber = &quot; & recnum
rs.Open strSQL, &quot;DSN=VisitorBook&quot;
rs.ActiveConnection = Nothing

'READ AND DISPLAY INFO FROM RECORDSET

rs.Close
set rs = Nothing
%>
The CursorLocation = 3 and rs.ActiveConnection = Nothing is my personal preference. This frees up resources on the server as fast as possible for read only, free moving recordsets.

Insert, update or delete records.
Code:
<%
dim Con
dim strSQL
Set Con = Server.CreateObject( &quot;ADODB.Connection&quot;)
Con.Open &quot;DSN=VisitorBook&quot;
strSQL = &quot;DELETE FROM VisitorBook WHERE RecordNumber = &quot; & recnum
Con.Execute strSQL
Con.close
set Con = Nothing
%>
Where strSQL can be DELETE FROM or INSERT INTO or UPDATE SQL Statements.

I'm just typing from memory here, without looking at my physical code, but these should work no problem. I'm assuming that your DSN name is VisitorBook.

ToddWW
 
Thanks ToddWW
The script is now working <phew>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top