
Ways to get single value or aggregates from db
There's not really a parallel in VB6/SQL Server, but you can do the same
thing with simple SQL statements:
DLookup:
SELECT File_Name FROM Some_Table WHERE File_ID = 3
DCount:
SELECT Count(File_Name) FROM Some_Table [WHERE File_ID = 3]
'Counts non-null File_Name entries
or
SELECT Count(*) FROM Some_Table [WHERE File_ID = 3]
'Counts records
DMax:
SELECT Max(File_Name) FROM Some_Table [WHERE File_ID = 3]
Learn the Structured Query Language (SQL) and database normalization
principles and techniques (if you don't already), and learn to create your
own ADO recordsets in code. Do not get used to the data control(s) - they
will get you in trouble at some point!
Good Luck and HTH,
Tore.
Quote:
> I am newbie on VB, just moved from Access VBA up to VB6 and SQL server. In
> Access or Access ADP, we have DLookup, DCount, Dmax... those handy
built-in
> functions to get a single value in VB from database. Say, a table in SQL
> Server with two columns: File_ID, File_Name.
> How can I get the File_Name for File_ID = 3? or the current maximum
File_ID?
> I know how to deal with recordsets in VB code, but those simple stuff
> (single value retrieval) stuck me. Help Please.
> Shao