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!

Update database

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
I am trying to update records in my database but am continually get a error saying that the database or object is read only. Can anyone please tell why this is so - it is driving me crazy!

I have included the adovbs.inc file and I am using an access2000 database

here is my code

---------------------------------
connectionstring
----------------------------------

Function openDB()

dim dcnDB, filepath

filepath = Server.MapPath("/Service Directory/Service Directory.mdb")

set dcnDB = Server.CreateObject("ADODB.Connection")
dcnDB.Connectionstring ="provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & filepath
dcnDB.open

set openDB = dcnDB

End Function


----------------------------------------------------------------------------------------------------------------------------------------
record set
------------------------------------------------------------------------------------------------------------------------------------------
set objRSpassupdate = Server.CreateObject("ADODB.Recordset")
objRSpassupdate.open "organisationbody", openDB, adopenKeyset, adLockoptimistic objRSpassupdate("organisationbodyname") = usernamecheck
objRSpassupdate("password") = passwordcheck
objRSpassupdate.Update
objRSpassupdate.close
openDB.close


the error I am getting is:

Error Type:
Microsoft JET Database Engine (0x80040E09)
Cannot update. Database or object is read-only.
/service directory/login.asp, line 45
 
Try to use this way, cuz i got this problemn to when i use Microsoft.Jet.OLEDB...

Code:
Set Connection=Server.CreateObject("ADODB.Connection")
dbPath=Server.MapPath("yourdatabase.mdb")
Connection.Open "DRIVER={Microsoft Access Driver (*.mdb)};DBQ="&dbPath

Const adOpenStatic = 3
Const adUseClient = 3
Const adLockPessimistic = 2

set rs=server.CreateObject("ADODB.Recordset")

sub ExecuteSQL(byval cmd)
    if rs.State=1 then rs.Close
    rs.CursorType = adOpenStatic
    rs.CursorLocation = adUseClient
    rs.LockType = adLockPessimistic
    rs.Source = cmd
    rs.ActiveConnection = Connection   'The record set needs to know what connection to use.
    rs.Open
end sub

querry="select * from yourtable"
ExecuteSQL(querry)


Hope this gives u an ideea...
but first try to use "DRIVER={Microsoft Access Driver (*.mdb)};DBQ="&dbPath
________
George, M
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top