Click here to Skip to main content
16,007,277 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralHelp !!!!! I am getting bogus poiner problem Pin
15-Oct-01 4:02
suss15-Oct-01 4:02 
GeneralRe: Help !!!!! I am getting bogus poiner problem Pin
Michael P Butler15-Oct-01 4:08
Michael P Butler15-Oct-01 4:08 
GeneralRe: Help !!!!! I am getting bogus poiner problem Pin
15-Oct-01 5:15
suss15-Oct-01 5:15 
GeneralRe: Help !!!!! I am getting bogus poiner problem Pin
Michael P Butler15-Oct-01 5:25
Michael P Butler15-Oct-01 5:25 
GeneralRe: Help !!!!! I am getting bogus poiner problem Pin
15-Oct-01 5:48
suss15-Oct-01 5:48 
GeneralRe: Help !!!!! I am getting bogus poiner problem Pin
15-Oct-01 5:48
suss15-Oct-01 5:48 
GeneralCArray and Windows CE Pin
Ray Kinsella15-Oct-01 3:52
Ray Kinsella15-Oct-01 3:52 
GeneralWeird ADO/ADOX problem Pin
Christian Graus15-Oct-01 3:37
protectorChristian Graus15-Oct-01 3:37 
I am creating a DB with ADOX, and it opens fine in Access, I can add records there. If I view the file in my program, opening the recordset like this:

	_RecordsetPtr records = NULL;
	 records.CreateInstance(__uuidof(Recordset));

	try
	{
		records->CursorType = adOpenStatic;
		records->CursorLocation = adUseClient;
		records->Open("SELECT * FROM FileDatabase",
		_variant_t((IDispatch*)m_Connection, true), adOpenKeyset, adLockOptimistic, 
		adCmdUnknown);
	}
	catch(...)//_com_error & e)
	{
//		MessageBox(NULL, e.ErrorMessage(), "", 0);
	}

	if (records->RecordCount == 0) return S_FALSE;

	records->MoveFirst();


It works. I do a do while !records->adoEOF and it reads everything in and displays it fine. I am trying to add records, and I use the exact same code to open then DB, but then I am checking each potential entry to make sure the primary key ( a filepath ) is not duplicated:

for (it = vecFileEntries.begin(); it != vecFileEntries.end(); ++it)
{
    // Get everything in order first
    if (records->RecordCount != 0)
        records->MoveFirst();

    CComBSTR bstrPath;
    (*it)->get_FilePath(&bstrPath);

    char * pStr = new char[bstrPath.Length() + 24];
    memset(pStr, 0, bstrPath.Length() + 24);
    sprintf(pStr, "[FilePath] = \'%s\'", (char*)(_bstr_t)bstrPath);

    try
    {
        records->Filter = (bstr_t)pStr;
    }
    catch (.../*_com_error & e*/)
    {
        MessageBox(NULL, "Error", pStr, 0);
    }

    if (records->adoEOF)
    {

and so on - the point is that here before AND after the filter, no matter how many records I have, the recordset->recordcount is always 1, and so nothing is ever added. I tried checking recordcount directly instead of adoEOF, I tried removing the check ( it crashed when trying to add records ). I've been through in Access to make sure the properties of the table are the same, I dunno what else to do.

This is how I create the file:

HRESULT hr = S_OK;

// Define ADOX object pointers.
// Initialize pointers on define.
// These are in the ADOX::  namespace.
ADOX::_CatalogPtr m_pCatalog = NULL;
ADOX::_TablePtr   m_pTable   = NULL;

try
{
    TESTHR(hr = m_pCatalog.CreateInstance(__uuidof(ADOX::Catalog)));

    char * pChar = new char[400];
    memset(pChar, 0, 400);
    sprintf(pChar, "Provider=Microsoft.Jet.OLEDB.4.0;Jet OLEDB:Engine Type=4;Data Source=%s;", (char*)DatabasePath);

    //Open the catalog
    m_pCatalog->Create(pChar);
    delete [] pChar;

    TESTHR(hr = m_pTable.CreateInstance(__uuidof(ADOX::Table)));
    m_pTable->PutName("FileDatabase");
    m_pTable->Columns->Append("FileName",ADOX::adVarWChar, 255);
    m_pTable->Columns->Append("FilePath",ADOX::adVarWChar,255);
    m_pTable->Columns->Append("FileLength",ADOX::adInteger,0);
    m_pTable->Columns->Append("TimesDownloaded",ADOX::adInteger,0);
    m_pTable->Columns->Append("LastModified",ADOX::adInteger,0);
    m_pTable->Columns->Append("Frames",ADOX::adInteger,0);
    m_pTable->Columns->Append("Seconds",ADOX::adInteger,0);
    m_pTable->Columns->Append("Width",ADOX::adInteger,0);
    m_pTable->Columns->Append("Height",ADOX::adInteger,0);
    m_pCatalog->Tables->Append(
        _variant_t((IDispatch *)m_pTable));

}

catch(_com_error &e)
{
    // Notify the user of errors if any.
    _bstr_t bstrSource(e.Source());
    _bstr_t bstrDescription(e.Description());

    MessageBox(NULL, bstrDescription, bstrSource, 0);

    return E_FAIL;
}

catch (...)
{
    MessageBox(NULL, "General Error Creating Database", "Error", 0);
    return E_FAIL;
}

return S_OK;


Any help appreciated, as always.


Christian

As I learn the innermost secrets of the around me, they reward me in many ways to keep quiet.

Men with pierced ears are better prepared for marriage. They've experienced pain and bought Jewellery.
GeneralRe: Weird ADO/ADOX problem Pin
Rashid Thadha15-Oct-01 4:18
Rashid Thadha15-Oct-01 4:18 
GeneralCreate File with Custom Size Pin
Derek Price15-Oct-01 3:23
Derek Price15-Oct-01 3:23 
GeneralRe: Create File with Custom Size Pin
Rob Caldecott15-Oct-01 3:36
Rob Caldecott15-Oct-01 3:36 
GeneralRe: Create File with Custom Size Pin
Derek Price15-Oct-01 3:42
Derek Price15-Oct-01 3:42 
QuestionHow do i determine how many bytes of memory available Pin
Jase Jennings15-Oct-01 3:13
Jase Jennings15-Oct-01 3:13 
AnswerRe: How do i determine how many bytes of memory available Pin
Rob Caldecott15-Oct-01 3:22
Rob Caldecott15-Oct-01 3:22 
AnswerRe: How do i determine how many bytes of memory available Pin
15-Oct-01 6:32
suss15-Oct-01 6:32 
GeneralSending HTML mails Pin
ed welch15-Oct-01 1:14
ed welch15-Oct-01 1:14 
GeneralCComBSTR Memory Leak Pin
Anders Molin15-Oct-01 0:57
professionalAnders Molin15-Oct-01 0:57 
GeneralRe: CComBSTR Memory Leak Pin
Michael Dunn15-Oct-01 8:59
sitebuilderMichael Dunn15-Oct-01 8:59 
GeneralRe: CComBSTR Memory Leak Pin
Anders Molin15-Oct-01 9:50
professionalAnders Molin15-Oct-01 9:50 
QuestionHow to allow the user to choose language and... Pin
Joan M15-Oct-01 0:46
professionalJoan M15-Oct-01 0:46 
AnswerRe: How to allow the user to choose language and... Pin
Tomasz Sowinski15-Oct-01 2:58
Tomasz Sowinski15-Oct-01 2:58 
GeneralRe: How to allow the user to choose language and... Pin
Joan M15-Oct-01 5:57
professionalJoan M15-Oct-01 5:57 
Generalexcuse me ! Pin
15-Oct-01 0:04
suss15-Oct-01 0:04 
QuestionCan someone put me on the right track? Pin
foobat14-Oct-01 23:06
foobat14-Oct-01 23:06 
AnswerRe: Can someone put me on the right track? Pin
Rob Caldecott15-Oct-01 3:27
Rob Caldecott15-Oct-01 3:27 

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.