Perl and ADO work pretty much the same way as other ADO functions work. Your code needs a few other things to make it work.. you may be forgetting them. (this is untested code, but it basically correct).
Basically you need to make sure that:
- You created the object with CreateObject. This will initialize the ADO COM objects and do all the coCreateInstance stuff you need. It seems like you had, but it's before all of this.
- use strict; This can never hurt.
- You called the correct connection string or DSN name in the Open method.
That said, there are a few things that you need to check for in your code:
$RS = $Conn->Execute("SELECT * FROM affiliate where Affiliate_Number="
+.$an);
if(! $RS->BOF )
#Beginning of file, as in returned no records
{
$RS -> movelast;
$RS -> movefirst;
$RS -> Recordcount;
#This may be a nitpick point, but MoveLast, MoveFirst,
#and RecordCount are all case sensitive.
$sql="update affiliate set Affiliate_Refferals=Affiliate_Refferals+1 w
+here Affiliate_Number=".$an;
}else{
&error('bad_affiliate_number');
#I don't know what you are trying to do with this, but hey.
}
Also, check on the following:
- Does your ADO data driver for your particular DBI support the RecordCount method? I know that Access does not, and will return a -1 (if you are using really simple "home brewn databases").
- Quote your sql string input. I CANNOT stress this enough. This is a major security problem with many many websites. If you are simply stuffing $Request->Form('form') into $an, then you are running the risk of people doing malicious input into your database, such as "blah; drop database databasename;" Seriously, this is a major problem facing small time websites. Validate your input, either with a regular expression, or whatever else it takes. Develop an input library for yourself, and maintain it well.
I hope that clears up some of the confusion with ADO.