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 -
Error Type:
-
Microsoft JET Database Engine (0x80004005)
-
Operation must use an updateable query.
-
/test2.asp, line 13
-
Now the code: - Dim objConn, strConn
-
'CREATE STRING CONNECTION TO DATABASE
-
Set objConn = Server.CreateObject("ADODB.Connection")
-
strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("\thecircle.mdb")
-
-
'now connect to database - conn
-
objConn.Open(strConn)
-
-
mySql = "Update Staff SET Locked = 1 WHERE ID = 1"
-
-
objConn.Execute mySql
-
-
objConn.Close
-
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. -
<!-- #INCLUDE File="strConn.asp" -->
-
<%
-
'Dim all objects/variables used on page
-
Dim BadLogin, NumAttempts, Warning, MustEnter, Locked, objUser, Username, Password, strQuery, UsernameDB, PasswordDB
-
-
'Check to see if form has been submitted or not
-
If Request.Form("Login") = "loginme" Then
-
'Here we begin the form processing code, otherwise move to the else
-
-
'Set Username and Password variables
-
Username = Request.Form("Username")
-
Password = Request.Form("Password")
-
-
'Check for a bad submission.
-
If Username = "" OR Password = "" Then
-
'Ok, bad form submission. Cannot process blank fields.
-
'So now we set the MustEnter and redirect the end user. Since
-
'in reality we could NEVER log a user in with a blank password
-
'or username, we will not increment the NumAttempts variable.
-
Response.Redirect "test.asp?Redirect=1&NumAttempts=0&MustEnter=1"
-
Else
-
'Ok, so both Username and Password have values. This means we need
-
'to attempt to log in an actual account. Also, time to get the number
-
'of attempts this user has tried to log in.
-
NumAttempts = Cint(Request.Form("NumAttempts"))
-
-
'create the objUser and populate it from the database. This is the
-
'object needed to compare the submission to the database to either
-
'allow the user or not.
-
strQuery = "SELECT * from Staff where Username='"& Username &"'"
-
Set objUser = Server.CreateObject("ADODB.Recordset")
-
objUser.Open strQuery, objConn
-
-
If NOT objUser.EOF Then
-
'Let's check the account to see if it is a locked account. Locked
-
'accounts should only be allowed on after review AND discussion with
-
'the web administrator. Also, confirm the IP address that locked the account
-
If objUser("Locked") = 1 Then
-
'Ok, so this account is locked. Let's redirect the user to the page and
-
'let them know what is up. They won't be able to get into the system until
-
'they've spoken with the web administrator. However, do not show them the
-
'IP address that locked the account. It's how to determine if it was them
-
'accidently screwing up or someone else trying to break in
-
Response.Redirect "test.asp?NumAttempts=0&Redirect=1&Locked=1"
-
Else
-
PasswordDB = objUser("Password")
-
NumAttempts = Cint(Request.Form("NumAttempts")) + 1
-
-
'Ok, so let's check the passwords and see if the user submitted the correct
-
'one with their username.
-
If Password <> PasswordDB Then
-
'If a bad password was submitted, count the attempts. If less than 3
-
'then return with increment. If 3 or more, lock account
-
If NumAttempts = 3 Then
-
'Ok, this user has tried too many times to log in. Time to lock the
-
'account for satefy sake.
-
strQuery = "UPDATE Staff SET Staff.Locked = 1 WHERE Staff.Username="& Username &";"
-
objConn.Execute(strQuery)
-
-
Response.Redirect "test.asp?Redirect=1&Locked=1"
-
Elseif NumAttemps = 2 Then
-
Response.Redirect "test.asp?Redirect=1&NumAttempts="& NumAttempts &"&BadLogin=1&Warning=1"
-
Else
-
Response.Redirect "test.asp?Redirect=1&NumAttempts="& NumAttempts &"&BadLogin=1"
-
End If
-
Else
-
'Ok, good user and good password. Set system, then redirect to homepage
-
'Set Session Variable for this user
-
Session("Name") = objUser("Username")
-
If objUser("Rank") = 1 Then
-
Session("Menu") = "Full"
-
Else
-
Session("Menu") = "Advanced"
-
End If
-
GoodLogin = "Success"
-
End If
-
End If
-
Else
-
'Ok, so no user could be found with that username. Let them know this.
-
'Also, this again, does not increment NumAttempts since no account has
-
'actually been accessed. This only causes a bad login to occur
-
Response.Redirect "test.asp?NumAttempts=0&Redirect=1&BadLogin=1"
-
End If
-
End If
-
Else
-
'Now, since the form was not submitted, we need to check to see
-
'if a redirection has occurred. If so, then operate using those
-
'variables, otherwise the form should look new.
-
If Request.Querystring("Redirect") = "1" Then
-
'Ok, so the form was submitted and something was wrong. Let's
-
'begin to process what it was by defining our variables
-
BadLogin = Request.Querystring("BadLogin")
-
NumAttempts = Request.Querystring("NumAttempts")
-
Warning = Request.Querystring("Warning")
-
MustEnter = Request.Querystring("MustEnter")
-
Locked = Request.Querystring("Locked")
-
Else
-
'Ok, so the form wasn't submitted and the user has not been here
-
'before. This means a blank, new form should be loaded with the
-
'correct values for the correct variables.
-
NumAttempts = 0
-
End If
-
End If
-
This code above also generates the same error about must use an updateable query..etc. Really frustrated at this point.
-Dave
1 1887
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.
Sign in to post your reply or Sign up for a free account.
Similar topics |
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.
|
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...
|
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...
|
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().
|
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...
| |
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
|
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...
|
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...
|
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.
|
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...
|
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...
| |
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...
|
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...
|
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();...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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
| |
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...
| |