Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 144
  • Last Modified:

ADO update problem

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
leonzhou
Asked:
leonzhou
  • 4
1 Solution
 
rajgnCommented:
What is the error you're getting?
0
 
sybeCommented:
$Sqlstat = "UPDATE Mytable SET city = 'city 1' where UserID = \'$userid\'";
$Conn->Execute($Sqlstat);
0
 
leonzhouAuthor Commented:
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
Technology Partners: 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!

 
leonzhouAuthor Commented:
$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
 
leonzhouAuthor Commented:
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
 
leonzhouAuthor Commented:
I got the answer by myself. It's actually very simple, I made a mistake. Anyway, I give you 200 points.
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now