Click here to Skip to main content
16,010,392 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Windows msg handlers Pin
Anonymous15-Aug-02 4:54
Anonymous15-Aug-02 4:54 
GeneralRe: Windows msg handlers Pin
Tomasz Sowinski15-Aug-02 4:57
Tomasz Sowinski15-Aug-02 4:57 
QuestionHow to get local path from a shared folder name? Pin
Tida15-Aug-02 4:13
Tida15-Aug-02 4:13 
AnswerRe: How to get local path from a shared folder name? Pin
Alberto Giannetto15-Aug-02 4:27
Alberto Giannetto15-Aug-02 4:27 
GeneralCompiling Visual C++ .NET projects from command line Pin
James Pullicino15-Aug-02 4:09
sussJames Pullicino15-Aug-02 4:09 
GeneralRe: Compiling Visual C++ .NET projects from command line Pin
Stuart Dootson15-Aug-02 11:05
professionalStuart Dootson15-Aug-02 11:05 
GeneralLogon script and dial up Pin
Alberto Giannetto15-Aug-02 3:45
Alberto Giannetto15-Aug-02 3:45 
Generalstaement executes once then next time around -exception Pin
ns15-Aug-02 3:33
ns15-Aug-02 3:33 
I am repeatedly accessing this function in my database app:

void CTrain1View::GetPhotoDB(CString m_PhotoDBName,CString m_MineName)
{

	if (m_photoDb.IsOpen()) m_photoDb.Close();

	m_photoDb.OpenPhotoDb(m_PhotoDBName, m_MineName);


}


where

int DbClass::OpenPhotoDb(CString PhotoDBName, CString MineName)
{
	try	
		{
	
		
		if (FAILED (m_pConnPhoto->Open (_bstr_t ("Provider=Microsoft.Jet.OLEDB.4.0;Data     Source = "+ PhotoDBName ),_bstr_t (""), _bstr_t (""), adModeUnknown)))
			{
			AfxMessageBox ("Can't open datasource");
			return -1;
			}

		CString partQuery = "'"+MineName+"'";



		CString SQLQ = "SELECT * FROM tblMine WHERE (DefID = "+partQuery+")";

		char*  SQLQuery = new char [SQLQ.GetLength()+1];

		strcpy(SQLQuery, SQLQ);


		m_pCommandPhoto->ActiveConnection = m_pConnPhoto;
		m_pCommandPhoto->CommandText= SQLQuery;  

	
		m_pRecordsetPhoto->CursorLocation = adUseClient;
		m_pRecordsetPhoto->Open ((IDispatch *) m_pCommandPhoto, vtMissing, adOpenKeyset,
							adLockOptimistic, -1);

		delete[] SQLQuery;
		return num;
		}
	catch(_com_error)

	{

	// Pass a connection pointer.

	   PrintProviderError(m_pConn);

	}


}


The second time I call the first function, and it calls OpenPhotoDB, there is a com error at:
if (FAILED (m_pConnPhoto->Open (_bstr_t ("Provider=Microsoft.Jet.OLEDB.4.0;Data     Source = "+ PhotoDBName ),_bstr_t (""), _bstr_t (""), adModeUnknown)))
    {
    AfxMessageBox ("Can't open datasource");
    return -1;
    }


even though as you can see, I did close the db before trying to open it again. Any one know ADO to help me out. I'm opening and then closing it before trying to open it again, so why does it choke?

Thanks,
ns
GeneralRe: staement executes once then next time around -exception Pin
Ranjan Banerji15-Aug-02 3:37
Ranjan Banerji15-Aug-02 3:37 
GeneralRe: staement executes once then next time around -exception Pin
ns15-Aug-02 3:46
ns15-Aug-02 3:46 
GeneralRe: staement executes ...error checking doesnt report anything: Pin
ns15-Aug-02 3:41
ns15-Aug-02 3:41 
QuestionHow to set quota limits of disk in VC++ Pin
Tida15-Aug-02 3:00
Tida15-Aug-02 3:00 
GeneralRegistry script problem Pin
pankajdaga15-Aug-02 2:53
pankajdaga15-Aug-02 2:53 
GeneralRe: Registry script problem Pin
Jon Hulatt16-Aug-02 2:32
Jon Hulatt16-Aug-02 2:32 
Questiondynamic button on CFormView Child ?? Pin
AlinRO15-Aug-02 2:30
AlinRO15-Aug-02 2:30 
AnswerRe: dynamic button on CFormView Child ?? Pin
Roger Allen15-Aug-02 3:56
Roger Allen15-Aug-02 3:56 
Questiondynamic button on CFormView ??? Pin
AlinRO15-Aug-02 2:29
AlinRO15-Aug-02 2:29 
AnswerRe: dynamic button on CFormView ??? Pin
Alberto Giannetto15-Aug-02 3:48
Alberto Giannetto15-Aug-02 3:48 
GeneralRegistry problem... Pin
code dope15-Aug-02 1:08
code dope15-Aug-02 1:08 
GeneralRe: Registry problem... Pin
Anders Molin15-Aug-02 2:08
professionalAnders Molin15-Aug-02 2:08 
GeneralRe: Registry problem... Pin
567890123415-Aug-02 2:34
567890123415-Aug-02 2:34 
GeneralRe: Registry problem... Pin
code dope15-Aug-02 2:54
code dope15-Aug-02 2:54 
GeneralRe: Registry problem... Pin
567890123415-Aug-02 3:20
567890123415-Aug-02 3:20 
GeneralRe: Registry problem... Pin
code dope15-Aug-02 2:50
code dope15-Aug-02 2:50 
GeneralRe: Registry problem... Pin
Anders Molin15-Aug-02 4:23
professionalAnders Molin15-Aug-02 4:23 

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.