Solved

ADO update problem

Posted on 1998-10-28
6
126 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
Comment Utility
What is the error you're getting?
0
 
LVL 28

Accepted Solution

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

Author Comment

by:leonzhou
Comment Utility
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
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 

Author Comment

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

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

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 …
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…
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 demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

762 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

6 Experts available now in Live!

Get 1:1 Help Now