#include ". \.. \common\io\appdirectoryutil.h "
#include ". \.. \common\database\dbconnection.h "
#include ". \.. \common\database\dbcommand.h "
#include ". \.. \common\database\dbdatareader.h "
Static CString getconnectionstring ()
{
CString mdbfilename = cappdirectoryutil::getparentdirectory () + TEXT ("\\biaozhun.mdb");
Return TEXT ("Provider=Microsoft.Jet.OLEDB.4.0;Data source=") + mdbfilename;
}
BOOL Carxellipsoidalhead::oninitdialog ()
{
Cdbconnection con (getconnectionstring ());
Con. Open ();
CString sql = TEXT ("select * from Biaozhun Where ID > 0");
Cdbcommand cmd (sql, &con);
Cdbdatareader *pdr = cmd. ExecuteReader ();
while (Pdr->read ())
{
Long ID = (PDR) [TEXT ("id")]. ToDouble ();
CString Biaozhun = (*PDR) [TEXT ("Biaozhun")]. ToString ();
M_standard. AddString (Pdr->operator [] (TEXT ("Biaozhun"));
M_standard. AddString (Biaozhun);
Dr->movenext ();
CString author = (*DR) [TEXT ("Author")]. ToString ();
CString Press = (*DR) [TEXT ("Press")]. ToString ();
Double price = (*DR) [TEXT ("Price")]. ToDouble ();
acutprintf (TEXT ("\nid:%d, biaozhun:%s"), Id,biaozhun);
}
Pdr->close ();
Con. Close ();
VC adds data from an Access database table to a ComboBox, implementing the properties of adding a ComboBox from the database