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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Database won't update

Status
Not open for further replies.

bobbygwd

Programmer
Jun 21, 2001
15
US
Below is the code:

----------------

<% option explicit %>
<html>
<head>
<title>Main Page</title>
<style>
.mystyle {font-family:tahoma,serif;font-size:10pt}
</style>
</head>
<body>
<!--#include file=&quot;strConnect.asp&quot;--> 'basic access server connection
<br><br><br><br>

<table align=center cellpadding=2 cellspacing=0><tr><td bgcolor=&quot;#333333&quot;>
<table align=center cellpadding=0 cellspacing=0 width=190>
<tr><td bgcolor=&quot;#000000&quot;><div align=&quot;center&quot; style=&quot;color:white&quot; class=&quot;mystyle&quot;><b>Main Page: </b></div></td></tr>

<tr><td bgcolor=&quot;#CCCCCC&quot;>
<br>
<blockquote>
<div align=&quot;center&quot; class=&quot;mystyle&quot;>

<%
dim myname, myoldpassword, mynewpassword, conntemp, rstemp, sqltemp, levelcase, linklevel

myname=request.form(&quot;username&quot;)
myoldpassword=request.form(&quot;oldpassword&quot;)
mynewpassword=request.form(&quot;newpassword&quot;)

set conntemp=server.createobject(&quot;adodb.connection&quot;)
set rstemp=server.createobject(&quot;adodb.recordset&quot;)
conntemp.open strConnect

rstemp.open &quot;users&quot;, conntemp

sqltemp=&quot;select * from users where user = '&quot;& myname &&quot;' ;&quot;

set rstemp=conntemp.execute(sqltemp)

If rstemp.eof then %>

We dont have a user named <% =&quot;<i>&quot; & Ucase(myname) & &quot;</i>&quot; %>
on file! <br><br>

<a href='changepass.asp'>Try again</a>
<br><br>

<% response.end
end if

if rstemp(&quot;password&quot;).Value=myoldpassword then

rstemp(&quot;password&quot;).Value=mynewpassword
rstemp.Update

response.write &quot;Password Changed!<br><br><a href='login.asp'>Log in</a><br><a href='index.asp'>Main Page</a><br><br>&quot;

else %>

Passwords Don't Match <br><br>

<a href='changepass.asp'>Try again</a>
<br><br>
<% response.end
end if
rstemp.close
conntemp.close
set rstemp=nothing
set conntemp=nothing

%>

</div>
</blockquote>

</td></tr>
</table>

</td></tr></table>

</body>
</html>

-----------------
I am recieving the error:

800a0cb3 -
Object or provider is not capable of performing requested operation.
-line 53

This code takes three inputs from a previous form...
username
old password
new password
... in which I am attempting to have the code change the &quot;password&quot; field in the database to the new password placed in variable &quot;myNewPassword&quot;
I have bolded line 53 so it can be easily noticed.
This line is attempting to store the new password into the &quot;password&quot; field in the database.
I don't know why asp is having a problem with this line of code. I also don't know if it could be an error within the rest of the code that may be setting off that error.
So if someone could tell me how to fix this error it would be of much help.

Thanks in advance,
Bobby Gordon
 
isn't javascript, don't put a .value. Try just entering rstemp(&quot;password&quot;)=mynewpassword -Ovatvvon :-Q
 
.value is ok. It's the default method of the recordset, so whether you (as a developer) use it or not, is completely up to you.

However, the error is stemming from the fact that you have declared your recordset with the default properties (including adLockReadOnly), so it's not letting you update any fields.

Before you open your recordset, you need to declare your locktype to be something else. Here's a FAQ on the subject that would make some good reading. Examples included.

faq333-618

:)
paul
penny.gif
penny.gif
 
I changed the code to the following, as you said...
but I'm getting a different error now.
---------------------------
<% option explicit %>
<html>
<head>
<title>Bring me a Dream inc.</title>
<style>
.dream {font-family:tahoma,serif;font-size:10pt}
</style>
</head>
<body>
<!--#include file=&quot;strConnect.asp&quot;-->
<br><br><br><br>

<table align=center cellpadding=2 cellspacing=0><tr><td bgcolor=&quot;#333333&quot;>
<table align=center cellpadding=0 cellspacing=0 width=190>
<tr><td bgcolor=&quot;#000000&quot;><div align=&quot;center&quot; style=&quot;color:white&quot; class=&quot;dream&quot;><b>Main Page: </b></div></td></tr>

<tr><td bgcolor=&quot;#CCCCCC&quot;>
<br>
<blockquote>
<div align=&quot;center&quot; class=&quot;dream&quot;>

<%
dim myname, myoldpassword, mynewpassword, conntemp, rstemp, sqltemp, levelcase, linklevel, adOpenForwardOnly, adlockoptimistic, adcmdtable

myname=request.form(&quot;username&quot;)
myoldpassword=request.form(&quot;oldpassword&quot;)
mynewpassword=request.form(&quot;newpassword&quot;)

set conntemp=server.createobject(&quot;adodb.connection&quot;)
conntemp.open strConnect

set rstemp=server.createobject(&quot;adodb.recordset&quot;)
rstemp.open &quot;users&quot;, conntemp, adOpenForwardOnly, adLockOptimistic, adCmdTable


sqltemp=&quot;select * from users where user = '&quot;& myname &&quot;' ;&quot;
'users is the database table and user is the field name

set rstemp=conntemp.execute(sqltemp)

If rstemp.eof then %>

We dont have a user named <% =&quot;<i>&quot; & Ucase(myname) & &quot;</i>&quot; %>
on file! <br><br>

<a href='changepass.asp'>Try again</a>
<br><br>

<% response.end
end if

if rstemp(&quot;password&quot;)=myoldpassword then
rstemp(&quot;password&quot;)=mynewpassword
rstemp.Update

response.write &quot;Password Changed!<br><br><a href='login.asp'>Log in</a><br><a href='index.asp'>Main Page</a><br><br>&quot;

else %>

Passwords Don't Match <br><br>

<a href='changepass.asp'>Try again</a>
<br><br>
<% response.end
end if
rstemp.close
conntemp.close
set rstemp=nothing
set conntemp=nothing

%>

</div>
</blockquote>

</td></tr>
</table>

</td></tr></table>

</body>
</html>

-----------------------

ADODB.Recordset error '800a0bb9'

Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another.

-line 33

^---- The error

Why am I getting an error? Am I putting the wrong attributes in the wrong places for the recordset. Or do I need to use numbers instead of variables.


Thanks for the additional assistance,
Bobby Gordon
 
rstemp.open &quot;users&quot;, conntemp, adOpenForwardOnly, adLockOptimistic, adCmdTable

See where you have specified &quot;users&quot;?

The .open() method is expecting a valid SQL Statement there.

So, for example:

dim sql
sql = &quot;SELECT * FROM users&quot;
rstemp.open sql, conntemp, adOpenForwardOnly, adLockOptimistic, adCmdTable

Also, in order to use those enumerated constants, you'll need to make sure you've included the adovbs.inc file on your page, which I don't see up there.

Here's some info on that file, and a link to the actual file, if you wish to use it:

Otherwise, you'll need to use the integer constants that equate to those values, which you can find here:

let us know if there are any other problems.

:)
paul
penny.gif
penny.gif
 
I added the file using:
<!--#include virtual=&quot;/adovbs.inc&quot;-->

And I got the following error again:
--------

ADODB.Recordset error '800a0cb3'

Object or provider is not capable of performing requested operation.
 
Code:
set conntemp=server.createobject(&quot;adodb.connection&quot;)
conntemp.open strConnect

set rstemp=server.createobject(&quot;adodb.recordset&quot;)
rstemp.open &quot;users&quot;, conntemp, adOpenForwardOnly, adLockOptimistic, adCmdTable


sqltemp=&quot;select * from users where user = '&quot;& myname &&quot;' ;&quot;
'users is the database table and user is the field name

set rstemp=conntemp.execute(sqltemp)

------------------------------------------------------

This is a redundant piece of code, which is probably causing you some headaches. If you haven't changed what it looks like, then when you
Code:
set rstemp=conntemp.execute(sqltemp)
you are reopening the recordset, basically undoing your previous property declarations, since the .execute method of the connection object will only open a recordset using the default properties.

Try this on:
-------------------------------------------------
Code:
<%
dim myname, myoldpassword, mynewpassword, conntemp, rstemp, sqltemp, levelcase, linklevel, adOpenForwardOnly, adlockoptimistic, adcmdtable

myname=request.form(&quot;username&quot;)
myoldpassword=request.form(&quot;oldpassword&quot;)
mynewpassword=request.form(&quot;newpassword&quot;)

set conntemp=server.createobject(&quot;adodb.connection&quot;)
conntemp.open strConnect

set rstemp=server.createobject(&quot;adodb.recordset&quot;)

sqltemp=&quot;select * from users where user = '&quot;& myname &&quot;' ;&quot;

rstemp.open sqltemp, conntemp, adOpenForwardOnly, adLockOptimistic
---------------------------------------------------

for the entire piece of code there, and then go along with the rest of your logic.

Sorry I missed that the first time. I was hung up on the first problem.

:)
paul
penny.gif
penny.gif
 
FABULOUS! Good job paul. It works now.
I appreciate your help.

Bobby Gordon
 
man, a lot's happened since yesturday. (1a.m.) Good eye Paul, didn't notice that with the lock-types and such. -Ovatvvon :-Q
 

Hi friends

&quot;i m gettting this Error when i tried to addnew and update the data ,....
&quot;Object or provider is not capable of performing requested operation. &quot;

If anybody knows plss tell me

thanking you !!!
sohan
 
hi friends
i find the logic for the first problem... but now i got the new problem and that is ..it's adding the record into the database but BLANK... just bland recoed .. tried both way (1)get value into the variable then tranfer to the table fields (2) direct by textbox name.....

here is my code .. please help me
Thanking you
regards
sohan

!!!<%@ Language =VBScript %>
<% Option Explicit%>

<!-- #include file= &quot;adovbs.inc&quot; -->
<%
Dim MyConn, RS

Set MyConn=Server.CreateObject(&quot;ADODB.Connection&quot;)
MyConn.Open &quot;getdata&quot;
Set RS=Server.CreateObject(&quot;ADODB.RecordSet&quot;)


RS.open &quot;Friends&quot;, Myconn,2,2

RS.Addnew
RS(&quot;Name&quot;) = request.form(&quot;txtName&quot;)
RS(&quot;Streetaddress&quot;) = request.form(&quot;txtAddress&quot;)
Rs(&quot;City&quot;) = request.form(&quot;txtCity&quot;)
Rs(&quot;State&quot;) = request.form(&quot;txtState&quot;)
Rs(&quot;Zip&quot;) = request.form(&quot;txtZip&quot;)
Rs(&quot;Phone&quot;) = request.form(&quot;txtPhone&quot;)
RS.Update
rs.movelast

RS.Close

MyConn.Close
Set RS = Nothing
Set MyConn = Nothing
%>


<HTML>
<HEAD>
<TITLE>Submission Successful</TITLE>
</HEAD>
<BODY>
<font size=&quot;+2&quot; face=&quot;arial&quot;>Submission Successful!</font><hr>
<breakquote>
Please come again!<p>
<a href=&quot;form.asp&quot;>List Contacts</a>
</breakquote>
</BODY>
</HTML>

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top