Click here to Skip to main content
16,006,594 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Change Date format Pin
David Crow22-Sep-08 3:29
David Crow22-Sep-08 3:29 
Questionvariable reflection in class Pin
SeshaSridhar21-Sep-08 20:29
SeshaSridhar21-Sep-08 20:29 
AnswerRe: variable reflection in class Pin
_AnsHUMAN_ 21-Sep-08 20:38
_AnsHUMAN_ 21-Sep-08 20:38 
GeneralRe: variable reflection in class Pin
SeshaSridhar21-Sep-08 20:56
SeshaSridhar21-Sep-08 20:56 
QuestionUsing MySQl with VC++ Pin
tony_Udz21-Sep-08 20:27
tony_Udz21-Sep-08 20:27 
AnswerRe: Using MySQl with VC++ Pin
Rajesh R Subramanian21-Sep-08 20:41
professionalRajesh R Subramanian21-Sep-08 20:41 
AnswerRe: Using MySQl with VC++ Pin
nguyenbinh0721-Sep-08 22:01
nguyenbinh0721-Sep-08 22:01 
AnswerRe: Using MySQl with VC++ Pin
Sandeep Saini SRE22-Sep-08 1:33
Sandeep Saini SRE22-Sep-08 1:33 
Simple 7 Steps Big Grin | :-D
1)First of all import msado15.dll into your workspace

#import "C:\Program Files\Common Files\System\ADO\msado15.dll" \
no_namespace rename("EOF", "EndOfFile")

2)Initialize COM libraries using 

CoInitialize(NULL); 

3) Create connection & record set pointers

_ConnectionPtr pConn("ADODB.Connection");

_RecordsetPtr  pRst("ADODB.Recordset");

4) Open data base

#define STR_DATABASE L"DRIVER={sql server};SERVER=serverName;Database=datbaseName;" L"UID=sa; PWD=sa;"

HRESULT hr = S_OK; 

hr  = pConn->Open(STR_DATABASE, L"", L"", adOpenUnspecified);

if(FAILED(hr))
{
  AfxMessageBox ("Error instantiating Connection object\n");
}

5)Execute Query and read values

try
{
 CString strSQL("Select * From MyTable");
 pRst->Open( _variant_t(strSQL),_variant_t((IDispatch *) pConn,   true),adOpenDynamic, adLockReadOnly,adCmdText);

 if(!pRst->EndOfFile){
 CString strValue = (char*)(_bstr_t)pRst->Fields->Item["FieldName"]- >Value;

 int nValue = (long)pRst->Fields->Item["FieldName"]->Value; 

// Here "FieldName" is the column name of table. You will get the value of this column in the corresponding variable.

}

catch(_com_error &ce)
{
  AfxMessageBox(ce.ErrorInfo);
OR
  AfxMessageBox(ce.Description());

}     

6)Close connection and record set pointers

if(pRst->State == adStateOpen) 
   pRst->Close();
if(pConn->State == adStateOpen)
   pConn->Close();

7)UnInitialized COM library

  ::CoUninitialize();

GeneralRe: Using MySQl with VC++ Pin
tony_Udz22-Sep-08 2:20
tony_Udz22-Sep-08 2:20 
GeneralRe: Using MySQl with VC++ Pin
Sandeep Saini SRE22-Sep-08 17:16
Sandeep Saini SRE22-Sep-08 17:16 
QuestionBad Ptr Pin
T.RATHA KRISHNAN21-Sep-08 20:18
T.RATHA KRISHNAN21-Sep-08 20:18 
AnswerRe: Bad Ptr Pin
Member 553230521-Sep-08 21:06
Member 553230521-Sep-08 21:06 
GeneralRe: Bad Ptr Pin
T.RATHA KRISHNAN21-Sep-08 21:12
T.RATHA KRISHNAN21-Sep-08 21:12 
QuestionRe: Bad Ptr Pin
Mark Salsbery22-Sep-08 5:45
Mark Salsbery22-Sep-08 5:45 
QuestionWarnings when compiling the unicode resource file Pin
Taruni21-Sep-08 19:36
Taruni21-Sep-08 19:36 
QuestionArray Pin
john563221-Sep-08 19:25
john563221-Sep-08 19:25 
AnswerRe: Array [modified] Pin
enhzflep21-Sep-08 19:51
enhzflep21-Sep-08 19:51 
QuestionHow to a webserver in VC++ Pin
tns_ranjith21-Sep-08 19:19
tns_ranjith21-Sep-08 19:19 
AnswerRe: How to a webserver in VC++ Pin
Hamid_RT21-Sep-08 19:56
Hamid_RT21-Sep-08 19:56 
AnswerRe: How to a webserver in VC++ Pin
nguyenbinh0721-Sep-08 22:43
nguyenbinh0721-Sep-08 22:43 
QuestionHow to convert HDC to CBitmap? Pin
TooShy2Talk21-Sep-08 16:23
TooShy2Talk21-Sep-08 16:23 
AnswerRe: How to convert HDC to CBitmap? Pin
Hamid_RT21-Sep-08 20:05
Hamid_RT21-Sep-08 20:05 
AnswerRe: How to convert HDC to CBitmap? Pin
enhzflep21-Sep-08 20:43
enhzflep21-Sep-08 20:43 
QuestionNeed a help with TreeListView realization on C++ Winapi (without MFC) Pin
sax_0H21-Sep-08 11:13
sax_0H21-Sep-08 11:13 
AnswerRe: Need a help with TreeListView realization on C++ Winapi (without MFC) Pin
Mark Salsbery21-Sep-08 14:41
Mark Salsbery21-Sep-08 14:41 

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.