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.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.