Salve a tutti, ho un problema nell'utilizzare ADO e la programmazione WIN32 (NO MFC).
Ho creato una dialog box nella quale ho inserito 4 EDITBOX per visualizzare i record di un file Access e 2 BUTTON per andare avanti e indietro tra i record. Il problema è che per qualche ragione che non conosco per far funzionare il programma ad ogni CASE devo aprire la connessione al file Access e per questo negli EDITBOX viene visualizzato sempre la prima riga della tabella Access.
Son partito prendendo spunto dagli esempi fatti da Jonny_Deep (ottimi!).
Questo è il codice

codice:
#include "resource.h"

#import "msado15.dll" no_namespace rename("EOF", "EndOfFile")


BOOL CALLBACK DlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{

	CoInitialize(NULL);
	_RecordsetPtr pRec("ADODB.Recordset");
	_ConnectionPtr pConn("ADODB.Connection");
	_bstr_t strConn("DRIVER={Microsoft Access Driver (*.mdb)};UID=;PWD=;DBQ=Archivio.mdb");
	
	switch(message)
	{

		case WM_INITDIALOG:
		{


			try
			{
				pConn->Open(strConn,"","",adConnectUnspecified);
				pRec->Open("SELECT * FROM account", strConn, adOpenUnspecified, adLockOptimistic,adCmdText );


				pRec->MoveFirst();

				SetDlgItemText(hDlg,IDC_COD,(_bstr_t) pRec->GetFields()->GetItem("codice")->GetValue());
				SetDlgItemText(hDlg,IDC_USER,(_bstr_t) pRec->GetFields()->GetItem("username")->GetValue());
				SetDlgItemText(hDlg,IDC_PASS,(_bstr_t) pRec->GetFields()->GetItem("password")->GetValue());
				SetDlgItemText(hDlg,IDC_UTENTE,(_bstr_t) pRec->GetFields()->GetItem("utente")->GetValue());



				pRec->Close();
				pConn->Close();

			}
			catch(_com_error &exception)
			{
				if(&exception != NULL)
				{
					MessageBox(NULL,exception.Description(),exception.ErrorMessage(),MB_OK);
					exit(1);
				}
			}


		}
		return TRUE;

		case WM_COMMAND:

			switch(LOWORD(wParam))
			{

				case IDC_NEXT:
				{
					try
					{
						pConn->Open(strConn,"","",adConnectUnspecified);
						pRec->Open("SELECT * FROM account", strConn, adOpenUnspecified, adLockOptimistic,adCmdText );

						pRec->MoveNext();

						SetDlgItemText(hDlg,IDC_COD,(_bstr_t) pRec->GetFields()->GetItem("codice")->GetValue());
						SetDlgItemText(hDlg,IDC_USER,(_bstr_t) pRec->GetFields()->GetItem("username")->GetValue());
						SetDlgItemText(hDlg,IDC_PASS,(_bstr_t) pRec->GetFields()->GetItem("password")->GetValue());
						SetDlgItemText(hDlg,IDC_UTENTE,(_bstr_t) pRec->GetFields()->GetItem("utente")->GetValue());
						


					}
					catch(_com_error &exception)
					{
						if(&exception != NULL)
						{
							MessageBox(NULL,exception.Description(),exception.ErrorMessage(),MB_OK);
							exit(1);
						}
					}

				}
				break;


				case IDC_PREVIEW:
				{
					try
					{
						
						pConn->Open(strConn,"","",adConnectUnspecified);
						pRec->Open("SELECT * FROM account", strConn, adOpenUnspecified, adLockOptimistic,adCmdText );

						pRec->MovePrevious();

						SetDlgItemText(hDlg,IDC_COD,(_bstr_t) pRec->GetFields()->GetItem("codice")->GetValue());
						SetDlgItemText(hDlg,IDC_USER,(_bstr_t) pRec->GetFields()->GetItem("username")->GetValue());
						SetDlgItemText(hDlg,IDC_PASS,(_bstr_t) pRec->GetFields()->GetItem("password")->GetValue());
						SetDlgItemText(hDlg,IDC_UTENTE,(_bstr_t) pRec->GetFields()->GetItem("utente")->GetValue());

						pRec->Close();
						pConn->Close();

					}
					catch(_com_error &exception)
					{
						if(&exception != NULL)
						{
							MessageBox(NULL,exception.Description(),exception.ErrorMessage(),MB_OK);
							exit(1);
						}
					}


				}
				break;


				case WM_DESTROY:
				{


					CoUninitialize();
					EndDialog(hDlg,0);

				}
				return TRUE;	
			}

	}
	return FALSE;
}


int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR LpCmdLine, int nCmdLine)
{

	
	return DialogBox(GetModuleHandle(NULL),MAKEINTRESOURCE(IDD_DIALOG),NULL,DlgProc);


}
Ho già cercato in tutto il forum e internet e non ho trovato niente che mi possa aiutare.
Grazie.