ASP Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming Languages - MoreASP Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old April 20th, 2012, 10:01 AM
jmss66 jmss66 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2007
Posts: 6 jmss66 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 59 m 51 sec
Reputation Power: 0
Update a record using Prepared Statement

I am trying to include Prepare Statement in my program and so far I have learned how to do a select statement with parameter. Next I am trying to update a record but keep getting the error messge below:









Microsoft JET Database Engineerror '80004005'

Operation must use an updateable query.
/development/CheckLogin.asp, line 102



Here is my code where I am updating using Prepared Statement. I don't even know if how I am using prepared statement is correct.

Line 102 is objCMD.Execute

Code:





   Set objCmd = Server.CreateObject("ADODB.command")

   set rsUsers = Server.CreateObject("ADODB.Recordset")

   objCmd.ActiveConnection = objConn

   objCmd.Prepared = True

   objCmd.CommandType = adCmdText

   objCmd.CommandText = "UPDATE Member SET LastLogin = ?"

   objCmd.Parameters.Append(objCmd.CreateParameter("@LastLogin", adDate, adParamInput, Len(Now()), Now()))

    rsUsers.CursorType = adOpenKeyset

    rsUsers.LockType = adLockOptimistic

    objCmd.Execute()






Below is my code for the Select Statement which is doing fine. This one executes before the code above which I am having a problem with..



Code:

Dim rsUsers

Set objCmd = Server.CreateObject("ADODB.command")

set rsUsers = Server.CreateObject("ADODB.Recordset")

objCmd.ActiveConnection = objConn

objCmd.Prepared = True

objCmd.CommandType = adCmdText

objCmd.CommandText = "SELECT * FROM Member WHERE SSN = ?"

objCmd.Parameters.Append(objCmd.CreateParameter("@SSN", adChar, adParamInput, Len(strSSN), strSSN))

rsUsers.CursorType = adOpenKeyset

rsUsers.LockType = adLockOptimistic

rsUsers.Open = objCmd.Execute()




Please I am new to using Prepared Statement and asking for any assistance.

Thanks.

Reply With Quote
  #2  
Old April 20th, 2012, 12:43 PM
Ronster Ronster is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2007
Location: Charlotte
Posts: 412 Ronster User rank is First Lieutenant (10000 - 20000 Reputation Level)Ronster User rank is First Lieutenant (10000 - 20000 Reputation Level)Ronster User rank is First Lieutenant (10000 - 20000 Reputation Level)Ronster User rank is First Lieutenant (10000 - 20000 Reputation Level)Ronster User rank is First Lieutenant (10000 - 20000 Reputation Level)Ronster User rank is First Lieutenant (10000 - 20000 Reputation Level)Ronster User rank is First Lieutenant (10000 - 20000 Reputation Level)Ronster User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 5 Days 2 h 6 m 13 sec
Reputation Power: 143
The first thing I would try is to add a WHERE clause to your update statement. As it is now, it is going to change the LastLogin value for every use in the table.

So making it look like:

"UPDATE Member SET LastLogin = ? WHERE SSN = ?" would be a start.

Lastly.... not sure what that Now() is doing.

Honestly... while I did a lot of Classic ASP a few years ago... we didn't do it like this.

We just made the SQL statement a string.
Your SELECT statement would look like this:

"SELECT * FROM Member WHERE SSN = " + strSSN

and go from there. I never did variable substitution in the object quite like that.



As a test... maybe try to update a value in the Member table that is NOT a datetime value. Like the last name for example. Just a test to make sure that your UPDATE statement is working. But I suspect your problem might be involved with that DateTime field.

Reply With Quote
  #3  
Old April 20th, 2012, 06:57 PM
Doug G Doug G is offline
Grumpier Old Moderator
Dev Shed God 19th Plane (14000 - 14499 posts)
 
Join Date: Jun 2003
Posts: 14,235 Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level) 
Time spent in forums: 1 Month 4 Weeks 14 h 27 m 16 sec
Reputation Power: 4445
Quote:
Operation must use an updateable query.
Your .mdb file or it's folder probably doesn't allow writing by the web server user. Also check the %TEMP% directory permissions.
__________________
======
Doug G
======
It is a truism of American politics that no man who can win an election deserves to. --Trevanian, from the novel Shibumi

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreASP Programming > Update a record using Prepared Statement

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap