There're are several ways you could ue DAO(fastest but only singlethreaded), could use thr raw ODBC dll, or you could do what i'm doing,<br>
which seems easiest, in a method that you dont even have to declare the recordset format , using ADO.<br>
<br>
#import "C:\Program Files\Common Files\System\ADO\msado15.dll" rename_namespace("ADOCG"

rename("EOF","EndOfFile"

<br>
using namespace ADOCG;<br>
<br>
that'll include the ADO libraries<br>
<br>
_ConnectionPtr m_pConnection;<br>
this will declare a connection pointer to the database(whenever creating and assigning something to a recordset pointer, you'll either need to give it a connectino pointer, or tell it where to connect)<br>
m_pConnection.CreateInstance( __uuidof(Connection) );<br>
this will initialize it for usage<br>
<br>
<br>
::CoInitialize(NULL); <br>
[whenever working with recordsets i recomend initializing the COM enviroment before entering the function and ::CoUninitialize();<br>
before leaving a function]<br>
<br>
_RecordsetPtr m_pRecordSet; <br>
m_pRecordSet.CreateInstance( __uuidof(Recordset) );<br>
<br>
(as you can see connectino and recordset declaring, and initializing is pretty similar)<br>
<br>
Once you got a connectino open(you could make this global and have several recordsets use the same connection)<br>
(But in my situation, such as a multithreaded server , i assign a connection pointer to each thread which is turns has a recordset)<br>
<br>
m_pConnection->Open(L"DSN=ldap", L"", L"", -1);<br>
<br>
this it eh method i use, i know you can use the name of the database<br>
but the L"DSN=ldap" means in the ODBC32 control(located in control pannel)<br>
i've defined a systemwide link to the database and named it ldap<br>
(this makes it much easier than defining the path in vC++ all the time, just linking to the DSN name helps alot)<br>
<br>
now theres several ways you can do this to open and read info from a recordset<br>
I use Lots of SQL commands when opening a recordset<br>
(SQL QUery commands really help in determining a criteria for whats seleted in the recordset)<br>
<br>
for example:<br>
<br>
int CUT_FTPThread::OnCheckPassword(struct sUsers &CkPass)<br>
{<br>
::CoInitialize(NULL); _RecordsetPtr m_pRecordSet; m_pRecordSet.CreateInstance( __uuidof(Recordset) );<br>
int rt = FALSE; char sqlexec[255];<br>
if((lstrlen(CkPass.Password) <1) ¦¦ (lstrlen(CkPass.Email) < 1)) return FALSE;<br>
<br>
wsprintf(sqlexec,"select * from Users where Email = '%s' and Password = '%s'", CkPass.Email, CkPass.Password);<br>
m_pRecordSet->Open( sqlexec, m_pConnection.GetInterfacePtr(), adOpenDynamic, adLockOptimistic, adCmdText );<br>
<br>
if(!m_pRecordSet->EndOfFile)<br>
{<br>
strncpy(m_user,CkPass.Email,MAX_PATH-1);<br>
strcpy(CkPass.UID,FieldToChar(m_pRecordSet,L"UserID"

);<br>
m_pRecordSet->Close(); ::CoUninitialize(); return TRUE;<br>
}<br>
m_pRecordSet->Close(); <br>
::CoUninitialize(); <br>
return FALSE; <br>
}<br>
<br>
a simple "select * from TableNameHere" will store all the records and feilds from that table into the recordset<br>
you could do "Select FieldName from Table" to get just a feild of all the records<br>
same with "select field1,field2 from table" <br>
youc an select multiple tables, but i wont get into that right now<br>
<br>
the FieldToChar() command is something i made, to retreive the varient values, makes it easier for me<br>
<br>
char* CUT_FTPThread::FieldToChar(_RecordsetPtr recset, _variant_t Fieldname) {<br>
_variant_t tmpvariant; char tmpChar[255];<br>
tmpvariant = recset->GetCollect(Fieldname); strcpy(tmpChar,(_bstr_t)tmpvariant);<br>
return (tmpChar);<br>
}<br>
<br>
You'll get a warning with this about returning pointer of local variable, but it works as far as i've worked with it<br>
just dont assign the reference, make it return the value, not it's addresse then you'll be fine<br>
<br>
Inserting & Deleting:<br>
<br>
int CUT_FTPThread::InsertLDAP(LPSTR userid, LPSTR pcid, LPSTR ipAddress, int online)<br>
{<br>
::CoInitialize(NULL); _RecordsetPtr m_pRecordSet; m_pRecordSet.CreateInstance( __uuidof(Recordset) );<br>
char sqlexec[255];<br>
<br>
wsprintf(sqlexec,"delete * from LDAP where PCID = %s", pcid);<br>
m_pRecordSet->Open(sqlexec , m_pConnection.GetInterfacePtr(), adOpenDynamic, adLockOptimistic, adCmdText );<br>
<br>
if(online)<br>
{wsprintf(sqlexec,"Insert into LDAP (PCID, UID, Online, IP) values (%s,%s,1,'%s')",pcid, userid,ipAddress);}<br>
else<br>
{wsprintf(sqlexec,"Insert into LDAP (PCID, UID, Online, IP) values (%s,%s,0,'%s')",pcid, userid,ipAddress);}<br>
<br>
m_pRecordSet->Open(sqlexec, m_pConnection.GetInterfacePtr(), adOpenDynamic, adLockOptimistic, adCmdText );<br>
::CoUninitialize(); return TRUE;<br>
}<br>
<br>
<br>
Getting a Maximum value:<br>
m_pRecordSet->Open( "select max(UserID) as MaxUID from Users", m_pConnection.GetInterfacePtr(), adOpenDynamic, adLockOptimistic, adCmdText );<br>
<br>
almost all these other commands are in the help files, or located at MSDN for SQL Servers, and should be located in the<br>
Access97(at least) help file<br>
got more questions let me know <p>Karl<br><a href=mailto:kb244@bellsouth.net>kb244@bellsouth.net</a><br><a href=
</a><br>Experienced in , or have messed with : VC++, Borland C++ Builder, VB-Dos, VB1 thru VB6, Delphi 3 pro, Borland C++ 3(DOS), Borland C++ 4.5, HTML, ASP(somewhat), QBasic(hehe, yea it was 4.5 too, least i didnt start with COBOL)