If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ASP > Adding records in database

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-11-07, 04:49
Synapse1978 Synapse1978 is offline
Registered User
 
Join Date: Oct 2004
Posts: 24
Lightbulb Adding records in database

Good day to all :-)

I am creating my first ASP database application the connection to the database is successfull but when i try to add new records the following errors occured:

"Microsoft JET Database Engine (0x80040E09)
Cannot update. Database or object is read-only."

This is the code:

<%
dim strSQL
dim adocn
dim adors
set adocn = server.createobject("adodb.connection")
set adors = server.createobject("adodb.recordset")

adocn.connectionstring = "provider=microsoft.jet.oledb.4.0; Data source=" & Server.MapPath("guestbook.mdb")
adocn.open

strSQL = "SELECT tbguest.gid, tbguest.gcomments FROM tbguest;"

adors.CursorType = adLockOptimistic
adors.LockType = 3

adors.Open strSQL,adocn

adors.Addnew
adors.Fields("gid") = "1"
adors.Fields("gcomments") = "ton"
adors.update

adors.Close
Set adors = Nothing
Set adocn = Nothing

%>

By the way im using IIS web server and MS access database.
Please anybody can help. thank you in advance.
Reply With Quote
  #2 (permalink)  
Old 01-15-07, 04:01
KillerApp KillerApp is offline
Registered User
 
Join Date: Jul 2004
Posts: 23
In your code:

adors.CursorType = adLockOptimistic
adors.LockType = 3

You have set the cursor type to a lock constant. Your code really reads:


adors.CursorType = adOpenStatic ' adOpenStatic=3
adors.LockType = adLockOptimistic ' adLockOptimistic=3

You could try setting the cursor type to adOpenKeyset
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On