Solved

ADO update problem

Posted on 1998-10-28
6
129 Views
Last Modified: 2010-03-04
I encounted the problem when I use ADO to update table: I can retrieve value, but not update).Following is my code piece:
=========================================================
$adopenkeyset=1;
my $Conn;
if(!$Session->{'Session_Conn'}) {
$Conn = $Server->CreateObject("ADODB.Connection");
$Conn->Open( "MyDSN","","");
$Session->{'Session_Conn'}=$Conn;
}
$rst = $Server->CreateObject("ADODB.Recordset");
$Sqlstat = "SELECT * FROM Mytable where UserID = \'$userid\'";
$rst->Open($Sqlstat,$Session->{'Session_Conn'},$adopenkeyset);
$rst->Fields("City")->{Value}="city 1";
$rst->Update;
$rst->Close;
=========================================================
I'm working on Win95,PWS,MS Access97,ActivePerl Build502

Any advice is highly appreciated!
Thanks
Leon
0
Comment
Question by:leonzhou
  • 4
6 Comments
 
LVL 1

Expert Comment

by:rajgn
ID: 1205783
What is the error you're getting?
0
 
LVL 28

Accepted Solution

by:
sybe earned 200 total points
ID: 1205784
$Sqlstat = "UPDATE Mytable SET city = 'city 1' where UserID = \'$userid\'";
$Conn->Execute($Sqlstat);
0
 

Author Comment

by:leonzhou
ID: 1205785
Sybe,
I didn't try :
===============================
$Sqlstat = "UPDATE Mytable SET city = 'city 1' where UserID = \'$userid\'";
$Conn->Execute($Sqlstat);
==============================
I will try it tonight, and let you know. But I also want to use UPDATE method of ADO recordset.




ragjn,

I didn't get any error message from Errors collection.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:leonzhou
ID: 1205786
$Sqlstat = "UPDATE Mytable SET city = 'city 1' where UserID = \'$userid\'";
$Conn->Execute($Sqlstat);

This worked. But I couldn't give you 200 points. Because I want to use Recordset not Command. I didn't make it clear in my title, and your answer did solve "ADO Updade Problem", I decide to give you 100 points. But I don't know how to give it to you. Please let me know. And again, if you can help me to find out why Recordset couldn't update, or solve this use Recordset, I will give you another 200 points. That means total 300 points.

0
 

Author Comment

by:leonzhou
ID: 1205787
I found the problem in my code. So, I couldn't give you another 200 points. So far, I will get 100 points. But I have another question. If you can answer it, I give you total 200 points.
I use following statement to update a number field:
$rst->Fields("year")->{Value}=$Request->Form('year')->Item;
But it did wrongly. I would like to know how to update a field date type is number or date/time.
0
 

Author Comment

by:leonzhou
ID: 1205788
I got the answer by myself. It's actually very simple, I made a mistake. Anyway, I give you 200 points.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
hard perl script 16 154
Perl Sort Question 4 129
Perl Script - Remove column of data based on column value 2 50
Vb script to unzip a files and rename the files 5 80
In the distant past (last year) I hacked together a little toy that would allow a couple of Manager types to query, preview, and extract data from a number of MongoDB instances, to their tool of choice: Excel (http://dilbert.com/strips/comic/2007-08…
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

914 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now