Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 3.5 > ASP.NET 3.5 Basics
|
ASP.NET 3.5 Basics If you are new to ASP or ASP.NET programming with version 3.5, this is the forum to begin asking questions. Please also see the Visual Web Developer 2008 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 3.5 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 16th, 2009, 06:10 PM
Registered User
 
Join Date: Jan 2009
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default difficulty updating my access database with asp

...Help i cant update or insert data to my access data base using ASP but i can only retrieve data from access

THE ERROR FROM INTERNET EXPLORER I GET is
Technical Information (for support personnel)
Error Type:
Microsoft JET Database Engine (0x80040E09)
Cannot update. Database or object is read-only.
/begasp/bbAddUser.asp, line 17.....


The line 17 of bbAddUser.asp is......[code]rsUsers.AddNew[ /code ]
the full program bbAddUser.asp is below


Code:
 
 
<!-- #include file="bb.asp" -->
<%
  Dim rsUsers 
  Set rsUsers = Server.CreateObject ("ADODB.Recordset")
  rsUsers.Open "Members", objConn, adOpenForwardOnly, adLockOptimistic, adCmdTable     'basically to select(retrieve/filter)-adOpenForwardOnly from database, and add data to database- adLockOptimistic
 If Session("MemberID") <> "" Then                            'if session is not empty .someone is currently using the system.
 rsUsers.Filter = "MemberID = ' " & Session("MemberID") & " ' "
 Else
 rsUsers.Filter = "EMailAddress = ' " & Request.Form("email") & " ' AND Password = ' " & Request.Form("Password") & " ' "     'search for e-mail  password in database
                                                                                                                         'to determne if user is new or registered
     If rsUsers.EOF Then                                          'if false or   user not found ;he is new
 rsUsers.AddNew                                             'line 17
  'Else 
 'Email address and Password matched with DB records  -
 'In this case we ll allow this to update users personal details
    End If                                                         'this is loop if..else in anoda if..else
End If
                                                            'Now write personal detail to record set
rsUsers("EmailAddress") = Request.Form("email")
rsUsers("Password") = Request.Form("Password")
'rsUsers("FamilyName") = Request.Form("FamilyName")
rsUsers("GivenName") = Request.Form("GivenName")
'rsUsers("Phone") = Request.Form("Phone")
'rsUsers("PinID") = Request.Form("Pin")
'rsUsers("StreetAddress1") = Request.Form("Address1")
'rsUsers("StreetAddress2") = Request.Form("Address2")
'rsUsers("City") = Request.Form("City")
'rsUsers("State") = Request.Form("State")
'rsUsers("Country") = Request.Form("Country")
'rsUsers("Active") = True
'rsUsers("LastLogin") =  Now
 
 
'strSQL = "INSERT INTO Members (FamilyName,GivenName,EmailAddress,Password) VALUES ('rsUsers("FamilyName")','rsUsers("GivenName")','rsUsers("EmailAddress")','rsUsers("Password")')"   
 
rsUsers.Update                   'update the database
Dim StrName, StrValue
For each strField in rsUsers.Fields
 strName = strField.Name
 strValue = strField.Value
 Session(strName) = strValue
  Next
  Session("blnValidUser") = True
  Response.Redirect "bbMenuForRegisteredUsers.asp"
  %>







the bb.asp is the program to connect to my database
Code:
<!-- #include file="bb.asp" -->
<!-- METADATA TYPE="typelib" FILE="C:\Program Files\Common Files\System\ado\msado15.dll" -->
<%
  Dim objConn
  Set objConn = Server.CreateObject("ADODB.Connection")
  objConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\datastore\Bb.mdb"  '"Driver={Microsoft Access Driver (*.mdb)};DBQ=c:\datastore\Bbfoundation2009.mdb"  ' "DSN=bbf"        '
 
  If Session("blnValidUser") = True and Session("MemberID") = "" Then
  Dim rsMemberIDCheck
  Set rsMemberIDCheck = Server.CreateObject("ADODB.Recordset")
 
  Dim strSQL
  strSQL = "SELECT MemberID FROM Members" & _  
            "WHERE EMailAddress = ' " & Session("EMailAddress") & " ' ; "
 
  rsMemberIDCheck.Open strSQL, objConn
 
  If  rsMemberIDCheck.EOF Then
  Session("blnValidUser")= False
  Else
  Session("MemberID") = rsMemberIDCheck("MemberID")
  End If
  rsMemberIDCheck.Close
 
  Set rsMemberIDCheck = Nothing
 
  End If
 
%>
thank you very much for looking into my program
 
Old January 17th, 2009, 02:53 AM
Friend of Wrox
 
Join Date: Jun 2008
Posts: 1,649
Thanks: 3
Thanked 141 Times in 140 Posts
Default

First of all, fix your browser.
-- Click on the TOOLS menu
-- Click on INTERNET OPTIONS menu item
-- Click on ADVANCED tab
-- *UN*check "Show friendly HTTP error messages"
-- OK

Now you'll get both your own debug output and more usable error messages.

But the root problem here has nothing at all to do with your code.

Quite simply, your database file (e.g., your ".mdb" file) is *NOT* writable by the IIS web server. *YOU* may have given YOURSELF permission to write into that directory and file, but you didn't give the web server permission to do so. The web server will be running as (I believe, with ASP) "IWAM_xxxx" where "xxxx" is the name of the computer it is on. (With non-.NET ASP, the web server is "IUSR_xxxx" ... I don't think that's relevant here, but...) So...you need to give the right permissions in that directory *AND* to that file.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Updating a gridview control w/access database p3aul ASP.NET 1.0 and 1.1 Professional 0 October 2nd, 2007 06:14 PM
Problem Updating MS Access database javlet Java Databases 1 April 24th, 2007 07:16 AM
Difficulty writing javascript to access dom ldoyle Javascript How-To 2 February 23rd, 2007 11:25 AM
updating yes/no field in MS Access database enigma82 Classic ASP Databases 2 May 6th, 2005 11:04 AM
Updating from no access database penta Access 12 October 27th, 2004 05:06 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.