473,804 Members | 3,705 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Beginning to Dislike MS Access and ASP together

3 New Member
Ok, now I've run into another little hiccup in my application. The ability to update records already in existance. What is bugging me about this, is the code I will submit was what I found on forums and suggestions here and there on the Internet and very similiar to what is suggested on this forum too.

I've begun toi regret not having SQL Server for this little exercise I am coding since much of the code I have written in the past worked just fine with SQL Server and I still have application code from that app I could reuse. Anyways, enough about my regrets. Here is the error/problem

Expand|Select|Wrap|Line Numbers
  1. Error Type:
  2. Microsoft JET Database Engine (0x80004005)
  3. Operation must use an updateable query.
  4. /test2.asp, line 13
  5.  
Now the code:
Expand|Select|Wrap|Line Numbers
  1. Dim objConn, strConn
  2. 'CREATE STRING CONNECTION TO DATABASE
  3. Set objConn = Server.CreateObject("ADODB.Connection")
  4. strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("\thecircle.mdb")
  5.  
  6. 'now connect to database - conn
  7. objConn.Open(strConn)
  8.  
  9. mySql = "Update Staff SET Locked = 1 WHERE ID = 1"
  10.  
  11. objConn.Execute mySql
  12.  
  13. objConn.Close
  14. Set objConn
Ok, so.. why the heck am I getting an error. The query works JUST fine in MS Access' little Query Wizard and such.

What I hate is trying to figure this out now... with people expecting this site done... but not having the tools I am familiar with.

BTW, here is the alternative code.. that is actually on the page itself.
Expand|Select|Wrap|Line Numbers
  1. <!-- #INCLUDE File="strConn.asp" -->
  2. <%
  3.     'Dim all objects/variables used on page
  4.     Dim BadLogin, NumAttempts, Warning, MustEnter, Locked, objUser, Username, Password, strQuery, UsernameDB, PasswordDB
  5.  
  6.     'Check to see if form has been submitted or not
  7.     If Request.Form("Login") = "loginme" Then
  8.         'Here we begin the form processing code, otherwise move to the else
  9.  
  10.         'Set Username and Password variables
  11.         Username = Request.Form("Username")
  12.         Password = Request.Form("Password")
  13.  
  14.         'Check for a bad submission.
  15.         If Username = "" OR Password = "" Then
  16.             'Ok, bad form submission. Cannot process blank fields.
  17.             'So now we set the MustEnter and redirect the end user. Since
  18.             'in reality we could NEVER log a user in with a blank password
  19.             'or username, we will not increment the NumAttempts variable.
  20.             Response.Redirect "test.asp?Redirect=1&NumAttempts=0&MustEnter=1"
  21.         Else
  22.             'Ok, so both Username and Password have values. This means we need
  23.             'to attempt to log in an actual account. Also, time to get the number
  24.             'of attempts this user has tried to log in.
  25.             NumAttempts = Cint(Request.Form("NumAttempts"))
  26.  
  27.             'create the objUser and populate it from the database. This is the
  28.             'object needed to compare the submission to the database to either
  29.             'allow the user or not.
  30.             strQuery = "SELECT * from Staff where Username='"& Username &"'"
  31.             Set objUser = Server.CreateObject("ADODB.Recordset")
  32.             objUser.Open strQuery, objConn
  33.  
  34.             If NOT objUser.EOF Then
  35.                 'Let's check the account to see if it is a locked account. Locked
  36.                 'accounts should only be allowed on after review AND discussion with
  37.                 'the web administrator. Also, confirm the IP address that locked the account
  38.                 If objUser("Locked") = 1 Then
  39.                     'Ok, so this account is locked. Let's redirect the user to the page and
  40.                     'let them know what is up. They won't be able to get into the system until
  41.                     'they've spoken with the web administrator. However, do not show them the
  42.                     'IP address that locked the account. It's how to determine if it was them
  43.                     'accidently screwing up or someone else trying to break in
  44.                     Response.Redirect "test.asp?NumAttempts=0&Redirect=1&Locked=1"
  45.                 Else
  46.                     PasswordDB = objUser("Password")
  47.                     NumAttempts = Cint(Request.Form("NumAttempts")) + 1
  48.  
  49.                     'Ok, so let's check the passwords and see if the user submitted the correct
  50.                     'one with their username.
  51.                     If Password <> PasswordDB Then
  52.                         'If a bad password was submitted, count the attempts. If less than 3
  53.                         'then return with increment. If 3 or more, lock account
  54.                         If NumAttempts = 3 Then
  55.                             'Ok, this user has tried too many times to log in. Time to lock the
  56.                             'account for satefy sake.
  57.                             strQuery = "UPDATE Staff SET Staff.Locked = 1 WHERE Staff.Username="& Username &";"
  58.                             objConn.Execute(strQuery)
  59.  
  60.                             Response.Redirect "test.asp?Redirect=1&Locked=1"
  61.                         Elseif NumAttemps = 2 Then
  62.                             Response.Redirect "test.asp?Redirect=1&NumAttempts="& NumAttempts &"&BadLogin=1&Warning=1"
  63.                         Else
  64.                             Response.Redirect "test.asp?Redirect=1&NumAttempts="& NumAttempts &"&BadLogin=1"
  65.                         End If
  66.                     Else
  67.                         'Ok, good user and good password. Set system, then redirect to homepage
  68.                         'Set Session Variable for this user
  69.                         Session("Name") = objUser("Username")
  70.                         If objUser("Rank") = 1 Then
  71.                             Session("Menu") = "Full"
  72.                         Else
  73.                             Session("Menu") = "Advanced"
  74.                         End If
  75.                         GoodLogin = "Success"
  76.                     End If
  77.                 End If
  78.             Else
  79.                 'Ok, so no user could be found with that username. Let them know this.
  80.                 'Also, this again, does not increment NumAttempts since no account has
  81.                 'actually been accessed. This only causes a bad login to occur
  82.                 Response.Redirect "test.asp?NumAttempts=0&Redirect=1&BadLogin=1"
  83.             End If
  84.         End If
  85.     Else
  86.         'Now, since the form was not submitted, we need to check to see
  87.         'if a redirection has occurred. If so, then operate using those
  88.         'variables, otherwise the form should look new.
  89.         If Request.Querystring("Redirect")  = "1" Then
  90.             'Ok, so the form was submitted and something was wrong. Let's
  91.             'begin to process what it was by defining our variables
  92.             BadLogin = Request.Querystring("BadLogin")
  93.             NumAttempts = Request.Querystring("NumAttempts")
  94.             Warning = Request.Querystring("Warning")
  95.             MustEnter = Request.Querystring("MustEnter")
  96.             Locked = Request.Querystring("Locked")
  97.         Else
  98.             'Ok, so the form wasn't submitted and the user has not been here
  99.             'before. This means a blank, new form should be loaded with the
  100.             'correct values for the correct variables.
  101.             NumAttempts = 0
  102.         End If
  103.     End If
  104.  
This code above also generates the same error about must use an updateable query..etc. Really frustrated at this point.

-Dave
May 18 '07 #1
1 1887
shweta123
692 Recognized Expert Contributor
Hi,

Try this code

Dim objConn, strConn
'CREATE STRING CONNECTION TO DATABASE
Set objConn = Server.CreateOb ject("ADODB.Con nection")
strConn = "Provider=Micro soft.Jet.OLEDB. 4.0;Data Source=" & Server.MapPath( "\thecircle.mdb ")

'now connect to database - conn
objConn.Open(st rConn)
objConn.Mode = 3 '3 = adModeReadWrite
mySql = "Update Staff SET Locked = 1 WHERE ID = 1"
objConn.Execute (mySql)

Also ,check for write permissions on IUSR_MACHINE account.
May 20 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

63
5945
by: Jerome | last post by:
Hi, I'm a bit confused ... when would I rather write an database application using MS Access and Visual Basic and when (and why) would I rather write it using Visual Studio .Net? Is it as easy in Visual Studio to create reports and labels as it's in Access?` The advantage of VS.net is that not every user needs Access, right? And that would eliminate the Access version problem as well I guess.
2
2517
by: Steven T. Hatton | last post by:
I came across this title while looking for something fairly unrelated (UML diagrams for C++ templates). The review quoted below is solidly positive. I'm not going to be able to run out an buy the book right now. I am still interested in opinions of people who have read it. Learning C++ is on a par with tensor analysis for me. It's damn hard! Anything that reduces the obstacles facing the beginner is worth promotting - IMHO. I'm still...
40
2169
by: Ari W. | last post by:
Does anybody here have any input on how to start learning C++. I am hoping nobody tells me to take courses. I am still in college and tried taking courses but found that all the details about pseudocode and other programming basics drove me insane. I think after taking that course and from general knowledge I have picked up I am pretty familiar with the way programs are built on a basic level at least. I am not looking to make a career...
4
1573
by: wenjie wang | last post by:
Greetings, I'd like to know is there any situation where your program could crash without reaching the breakpoint which you set at the beginning of main().
4
3441
by: AHP | last post by:
Hi, I'm using Visual Studio 2005. I am developing a web application that uses the FileUpload control to upload text files to a directory on a webserver. This works fine. However, for me to be able to further process the files, I need to insert some data at the BEGINNING of the text file. All the solutions I've seen either append the text to the end of the file, or overwrite the data at the start of the file, or read the entire file into...
1
1314
by: Kappa | last post by:
Hello I want people who are reading Beginning C# Objects: From Concept to Code by Jacquie Barker from Apress to get together and discuss any problems they come across during the read. We can discuss exercises and three case studies provided at the end of this book. Thanks for your response in advance. Kappa
8
6734
by: babyangel43 | last post by:
Hello, I have a query set up in Access. I run it monthly, changing "date of test". I would like this query to be merged with a Word document so that the cover letter is created in Word, the fields from Access are automatically filled into the Word document. The query could be anywhere from 0-5000 names, one cover letter per name. AND to this cover letter for each applicant, there has to be attached a two page document. How in the world can...
0
6226
by: Tony Hine | last post by:
Problem for Excel Developers One of the problems facing Excel developers moving into MS Access is actually the apparent similarity between MS Access tables and Excel spreadsheets. MS Access is NOT Excel This similarity of the “look” in both programs, the layout of the data, leads to the Excel developer mistakenly thinking that a database works in a similar way to a spreadsheet. Flat File Database Spreadsheets are very sophisticated...
4
4979
by: djaekimaar | last post by:
Hi. First I apologise if there is a better place to post this. Please let me know. I also apologise in advance if this is a really stupid mistake, but now seem to be bashing head against wall. I have some code that is creating an xml doc $dom = new DOMDocument(); $xmlDoc = $dom->appendChild($dom->createElement('root')); etc.
0
9705
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10568
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9138
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7613
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6847
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5516
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5647
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4292
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2988
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.