Click here to Skip to main content
15,917,617 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: move a control on dialog box Pin
_AnsHUMAN_ 20-Jun-06 20:47
_AnsHUMAN_ 20-Jun-06 20:47 
GeneralRe: move a control on dialog box Pin
yogendra kaushik20-Jun-06 20:54
yogendra kaushik20-Jun-06 20:54 
GeneralRe: move a control on dialog box Pin
_AnsHUMAN_ 20-Jun-06 21:04
_AnsHUMAN_ 20-Jun-06 21:04 
AnswerRe: move a control on dialog box Pin
Hamid_RT20-Jun-06 20:54
Hamid_RT20-Jun-06 20:54 
QuestionHelp on WinInet Programming Pin
Girish60120-Jun-06 20:09
Girish60120-Jun-06 20:09 
QuestionReading from Excel Pin
Anu_Bala20-Jun-06 19:55
Anu_Bala20-Jun-06 19:55 
AnswerRe: Reading from Excel Pin
Hamid_RT20-Jun-06 20:27
Hamid_RT20-Jun-06 20:27 
AnswerRe: Reading from Excel Pin
zeus_master20-Jun-06 22:59
zeus_master20-Jun-06 22:59 
you can find the CRecordset in the web...


it can open the excel as database

void CExDlg::OnRead()
{
// TODO: Add your control notification handler code here
CDatabase database;

CString sDriver;
CString sDsn;
CString sFile,sPath;


//find the excel in main exe folder
GetModuleFileName(NULL,sPath.GetBufferSetLength (MAX_PATH+1),MAX_PATH);
sPath.ReleaseBuffer ();
int nPos;
nPos=sPath.ReverseFind ('\\');
sPath=sPath.Left (nPos);
sFile = sPath + "\\Demo.xls"; //name of excel

sDsn.Format("ODBC;DRIVER={%s};DSN='';DBQ=%s", sDriver, sFile);

TRY
{
database.Open(NULL, false, false, sDsn);

CRecordset recset(&database);

CString sSql;
sSql = "SELECT item FROM Regt WHERE item = 'iwant' "; //
// exe SQL
recset.Open(CRecordset::forwardOnly, sSql, CRecordset::readOnly);



BYTE line = 1;
// »ñÈ¡²éѯ½á¹û
while (!recset.IsEOF())
{

//¶ÁÈ¡ExcelÄÚ²¿ÊýÖµ
recset.GetFieldValue("item", sitem); // read out the item

line++;

//ÏÔʾ¼ÇÈ¡µÄÄÚÈÝ
m_listbox.AddString( sitem);

// ÒƵ½ÏÂÒ»ÐÐ
recset.MoveNext();
}

// close
database.Close();

}
CATCH(CDBException, e)
{
// Êý¾Ý¿â²Ù×÷²úÉúÒ쳣ʱ...
AfxMessageBox("error: " + e->m_strError);
}
END_CATCH;

}
Questionneed .lib file Pin
trinadh_t20-Jun-06 18:47
trinadh_t20-Jun-06 18:47 
AnswerRe: need .lib file Pin
Steve Echols20-Jun-06 19:39
Steve Echols20-Jun-06 19:39 
GeneralRe: need .lib file Pin
trinadh_t20-Jun-06 20:21
trinadh_t20-Jun-06 20:21 
GeneralRe: need .lib file Pin
Cedric Moonen20-Jun-06 20:26
Cedric Moonen20-Jun-06 20:26 
GeneralRe: need .lib file Pin
trinadh_t20-Jun-06 20:34
trinadh_t20-Jun-06 20:34 
GeneralRe: need .lib file Pin
Cedric Moonen20-Jun-06 20:45
Cedric Moonen20-Jun-06 20:45 
GeneralRe: need .lib file Pin
trinadh_t20-Jun-06 20:56
trinadh_t20-Jun-06 20:56 
GeneralRe: need .lib file Pin
Steve Echols20-Jun-06 20:31
Steve Echols20-Jun-06 20:31 
GeneralRe: need .lib file Pin
trinadh_t20-Jun-06 20:41
trinadh_t20-Jun-06 20:41 
GeneralRe: need .lib file Pin
Steve Echols20-Jun-06 21:03
Steve Echols20-Jun-06 21:03 
GeneralRe: need .lib file Pin
trinadh_t20-Jun-06 21:11
trinadh_t20-Jun-06 21:11 
GeneralRe: need .lib file Pin
Steve Echols20-Jun-06 21:24
Steve Echols20-Jun-06 21:24 
AnswerRe: need .lib file Pin
Hamid_RT20-Jun-06 21:00
Hamid_RT20-Jun-06 21:00 
GeneralRe: need .lib file Pin
trinadh_t20-Jun-06 21:09
trinadh_t20-Jun-06 21:09 
GeneralRe: need .lib file Pin
Hamid_RT20-Jun-06 21:20
Hamid_RT20-Jun-06 21:20 
QuestionEditbox property change Pin
Ram Murali20-Jun-06 18:17
Ram Murali20-Jun-06 18:17 
AnswerRe: Editbox property change Pin
_AnsHUMAN_ 20-Jun-06 18:35
_AnsHUMAN_ 20-Jun-06 18:35 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.