what does this code mean?

what does this code mean?

rsLoadList.Open "select Name, Sex, dateofBirth, stake, Ward ,Left(((Date() - dateofbirth)/365.25),3) as age from SAnames where stake like " & whatstake & " and sex = " & whatGender & " and (((Left((Date()-[dateofbirth])/365.25,3))=" & whatAge & ")) order by name" _
, LDScon, adOpenDynamic, adLockOptimistic
[346 byte] By [matthewivan] at [2007-11-19 17:01:47]
# 1 Re: what does this code mean?
What you're looking at is a Recordset doing an Open command.

The whole first long part:
"select Name, Sex, dateofBirth, stake, Ward ,Left(((Date() - dateofbirth)/365.25),3) as age from SAnames where stake like " & whatstake & " and sex = " & whatGender & " and (((Left((Date()-[dateofbirth])/365.25,3))=" & whatAge & ")) order by name"is an SQL statement.

It is selecting the fields: Name, Sex, DateofBirth, Stake, and Ward.
It is converting the returned value of DateofBirth to reflect the age.
It is retrieving all of this information from the table SAnames.
It is only looking for records where the value of the field Stake is like, meaning not a direct match, but similar to, the passed value via the "whatStake" variable, where the value of the field Sex matches the passed value via the "whatGender" variable, and where the value of Age, determined by a comparison, matches via the "whatAge" variable.
Then, the results are sorted by the Name field.

... assuming, of course, that query actually works. I can't test it, and I don't know SQL that well. That's at least what it looks like it's trying to do.

LDScon is the Connection object.
adOpenDynamic is the cursor type, and adLockOptimistic is the lock type. I can't remember what exactly they do off the top of my head, but I'm positive I've always seen adLockOptimistic being used.

That is through ADODB objects (Project -> References... -> Microsoft ActiveX Data Objects 2.X Library), which are used for Database connectivity.

I assume that line came from a page of code and wasn't just by itself.
ChaosTheEternal at 2007-11-9 20:21:02 >
# 2 Re: what does this code mean?
is there any way that this code will be use in adodc or patterned before it?

what's the code?
matthewivan at 2007-11-9 20:21:56 >
# 3 Re: what does this code mean?
I may be wrong, since I rarely used ADODC (and never do anymore).

As is, with ADODC, it can be. Adding the controls for ADODC (Project -> Components... -> Microsoft ADO Data Control 6.0 (SP6), but your version may differ) seems to add the ADODB references automatically. Mine added the 2.5 reference (though I have 2.8 available).
Along the same lines as the Microsoft Internet Controls adding the WebBrowser control and the InternetExplorer object, some components add references automatically (though adding just the reference does not add the component in the same fashion).

I don't know how you can use both at the same time, mostly since I don't know how you really use ADODC, but I figure you can. You should at least be able to bind controls to the tables or query that the ADODC control uses.

If you want more information about ADODC, do search about it or wait until someone who knows more than me can help you.
ChaosTheEternal at 2007-11-9 20:23:05 >
# 4 Re: what does this code mean?
can you help me with this?

what i need is that when users enter a birthdate automatically the age is computed and is saved to the database and also the stored/saved ages of different persons will also automatically updated each tiime the program starts
matthewivan at 2007-11-9 20:24:04 >
# 5 Re: what does this code mean?
http://www.dev-archive.com/forum/showthread.php?t=370121#post1299633

Like I said there. You shouldn't store Age in the database along with DateOfBirth.
And I'm not all that proficient with ADODC. I can do ADODB well, but I don't know ADODC.

If you mean to just use ADODB (which is what I assumed regarding your first post where you use a Recordset object), I can help you a bit. You likely wouldn't need that confusing of a Select statement (SQL has a DateDiff function which would make determining years easier).

And please keep your posts in one topic if they are related.
ChaosTheEternal at 2007-11-9 20:25:08 >
# 6 Re: what does this code mean?
Just my 2 cents here.
ADODC is not a good way of doing database programming. For starters and learning purposes, it is ok if you use it in some practice projects. However, when you are doing live projects you should try to use ADODB rather than ADODC.

Writing code for your database operations gives you more flexibility.

My advice would be to use ADODB to do any kind of database operations.
Shuja Ali at 2007-11-9 20:26:01 >