Solved

ADO update problem

Posted on 1998-10-28
6
140 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Many time we need to work with multiple files all together. If its windows system then we can use some GUI based editor to accomplish our task. But what if you are on putty or have only CLI(Command Line Interface) as an option to  edit your files. I…
A year or so back I was asked to have a play with MongoDB; within half an hour I had downloaded (http://www.mongodb.org/downloads),  installed and started the daemon, and had a console window open. After an hour or two of playing at the command …
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…

751 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