400 points - Please help!!


I've submitted this question before and I haven't received any answers.  I've also submitted this in the database-general category, and between the three questions there's 400 points at stake.  Answer my question and I'll credit you the points for all three questions.  I suspect that it is not very difficult but I'm not very experienced with databases.  

I'm learning sql thru the SAMS text Database Progamming with Visual C++ in 21 days.  I'm going thru the example in day 4, which is to load the database engine into an list control.  Instead of loading properly, an exception is thrown, with the following information:

 Code Meaning = Unspecified error
 Source = Microsoft JET Database Engine
 Description = Couldn't find installable ISAM.

I also tried using the listings from the cd with the book.  Running that project, an error window pops up with the following message:

[MSFT][ODBC Driver Manager][Data source name not found and no default driver specified]

I take it this means something necessary isn't installed on my system.  I tried to reinstall all the data access files from the VC6 setup disk like the book recommends, but I don't know what files that installs or where they go.  In any case, it still doesn't work.  Can anybody help me on what I need to get to fix it?


koziscoolAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

captainkirkCommented:
[MSFT][ODBC Driver Manager][Data source name not found and no default driver specified]

You usually get this one if you have not set up a datasource with your ODBC configuration utility in the Control Panel...

What database(s) have you installed on your system???
0
kpcapelCommented:
I ran into this once when running a database application on Win98 that previously ran fine on NT 4.0.  I don't know what your connection string looks like or what OS you're running, but I used this connection string format originally:
DRIVER={Microsoft Access Driver(*.mdb)};DefaultDir=somepath;DBQ=theDatabaseName;

I changed the connection string to this format:
PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source =theFullPath"
This ended up working fine on both platforms.  By the way both the NT and 98 machines had the MS Data Access Components properly installed.  Unfortunately, I can't explain exactly why.
0
Gandalf32Commented:
kpcapel: The difference is that the first version uses ODBC, which requires a data source to be defined, and the second form uses OLE-DB, which doesn't, as the conenction string provides all the information necessary.
0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

koziscoolAuthor Commented:

In fact, the connection string is just as you wrote it, except that PROVIDER = Microsoft.Jet.OLEDB.3.51;

As far as the control panel ODBC utility goes, I put the file path there as a system dsn.  I'm still a little bit confused about what, if any difference that would make, since I thought that I was using OLE DB in lieu of ODBC.
0
Gandalf32Commented:
You are probably missing the OLE-DB driver for Jet 3.51. Try changing it to read PROVIDER=Microsoft.Jet.OLEDB.4.0. If this doesn't work either, you need to install an OLE-DB driver.
0
kpcapelCommented:
If you use PROVIDER=Microsoft.Jet.OLEDB.4.0;
and then Data Source=thePathToYourDB
and you have the Microsoft Data Access Components installed, you should have no problem.  No need for the ODBC control panel.
0
koziscoolAuthor Commented:

Thanks gandalf and kpc.  It still doesn't work, but I think we're on the right track.  I've tried to install all the Data Access Components from the VC60 setup disk, as well as from downloading mdac_typ.exe from Microsoft's web site.

Both seemed to run smoothly but my program doesn't work.  I'm wondering if either of you know exactly what files need to be in what directories, something such.  I'm at a loss what could be the problem, maybe a dll needs to be in a pathname, maybe the files are there but the OLE DB driver doesn't see them.

I'm increasing the points again, I really need this to work.
0
kpcapelCommented:
Would you mind pasting in all the offending code?
0
Gandalf32Commented:
Try the following:
Create a new MFC project. Just accept the default values for everything. Select to add a new ATL class. Choose a Data Access component, and create a new consumer. It will prompt you for the database type. Select the Jet driver, and choose your database. Leave all the other defaults as they are.
This will create a new class for you. Look in the class definition, and you will see the necessary connection string. Just copy it into your project.
This may seem a little twisted, but it will work for sure.
0
koziscoolAuthor Commented:

To kpc:

I'd be happy to paste in the offending code.  Unfortunately, as I'm sure you know, where the code breaks is not necessarily where the problem is.  But in any case, here goes.

m_pConnection is of type _ConnectionPtr and is declared as a member variable of the doc class.  The CreateInstance call works fine, but the Open call throws an exception and the trace window output is shown above.

BOOL CAdomfc1Doc::OnNewDocument()
{
      if (!CDocument::OnNewDocument())
            return FALSE;

      // TODO: add reinitialization code here
      // (SDI documents will reuse this document)

    HRESULT hr;

    try
    {
        hr = m_pConnection.CreateInstance( __uuidof( Connection ) );
        if( SUCCEEDED( hr ))
        {
            hr = m_pConnection->Open(
                _bstr_t(L"Provider=Microsoft.Jet.OLEDB.3.51;DataSource=c:\\Koz\\DatabaseTutorial\\SOURCE\\vcdb.mdb;" ),
                _bstr_t(L""),
                _bstr_t(L""),
                adModeUnknown );

            if( SUCCEEDED( hr ))
                m_IsConnectionOpen = TRUE;
        }
    }
    catch( _com_error &e )
    {
        // Get info from _com_error
        _bstr_t bstrSource( e.Source() );
        _bstr_t bstrDescription( e.Description() );
        TRACE( "Exception thrown for classes generated by #import" );
        TRACE( "\tCode = %081x\n", e.Error() );
        TRACE( "\tCode Meaning = %s\n", e.ErrorMessage() );
        TRACE( "\tSource = %s\n", (LPCTSTR)bstrSource );
        TRACE( "\tDescription = %s\n", (LPCTSTR) bstrDescription );
    }
    catch(...)
    {
        TRACE( "** unhandled exception " );
    }

      return TRUE;
}
0
Gandalf32Commented:
Your code seems OK (granting of course that the database is located at c:\Koz\DatabaseTutorial\SOURCE\vcdb.mdb :) ). Try what I recommended you, and check out the resulting connection string.
0
kpcapelCommented:
Code looks fine. I was expecting something small to be wrong. Just curious, did you have DCOM98 installed prior to MDAC_TYP?
0
koziscoolAuthor Commented:

To Gandalf:

That was quite an idea.  I assume you meant to say add an ATL object instead.

Well, I did your steps, and the connection was made and the following header produced.  Now where is the ConnectionString?  Do I need to concatenate everything in dbInit member variable and add it to the end of "Microsoft.Jet..."?

class COrders : public CCommand<CAccessor<COrdersAccessor> >
{
public:
      HRESULT Open()
      {
            HRESULT            hr;

            hr = OpenDataSource();
            if (FAILED(hr))
                  return hr;

            return OpenRowset();
      }
      HRESULT OpenDataSource()
      {
            HRESULT            hr;
            CDataSource db;
            CDBPropSet      dbinit(DBPROPSET_DBINIT);

            dbinit.AddProperty(DBPROP_AUTH_CACHE_AUTHINFO, true);

            dbinit.AddProperty(DBPROP_AUTH_ENCRYPT_PASSWORD, false);

            dbinit.AddProperty(DBPROP_AUTH_MASK_PASSWORD, false);

            dbinit.AddProperty(DBPROP_AUTH_PASSWORD, OLESTR(""));

            dbinit.AddProperty(DBPROP_AUTH_PERSIST_ENCRYPTED, false);

            dbinit.AddProperty(DBPROP_AUTH_USERID, OLESTR("Admin"));

            dbinit.AddProperty(DBPROP_INIT_DATASOURCE, OLESTR("C:\\Koz\\DatabaseTutorial\\SOURCE\\VCDb.mdb"));

            dbinit.AddProperty(DBPROP_INIT_MODE, (long)16);

            dbinit.AddProperty(DBPROP_INIT_PROMPT, (short)4);

            dbinit.AddProperty(DBPROP_INIT_PROVIDERSTRING, OLESTR(";COUNTRY=0;CP=1252;LANGID=0x0409"));

            dbinit.AddProperty(DBPROP_INIT_LCID, (long)1033);

            hr = db.Open(_T("Microsoft.Jet.OLEDB.3.51"), &dbinit);
            if (FAILED(hr))
                  return hr;

            return m_session.Open(db);
      }
      HRESULT OpenRowset()
      {
            return CCommand<CAccessor<COrdersAccessor> >::Open(m_session);
      }
      CSession      m_session;
};
0
koziscoolAuthor Commented:

Maybe Vcdb.mdb is case-sensitive?  I don't think so but...
0
Gandalf32Commented:
If this could connect correctly, it means that the OLE-DB data source is working ok.
Not everything added is necessary to connect. Apparently your connection string is OK, as it is the same as ATL used successfully. Just in case, try modifying the first _bstr_t(L"") to _bstr_t(L"Admin"). I believe (I don't have the documentation here now) that this is the username.
               
0
koziscoolAuthor Commented:

I already tried that ("Admin").  It didn't work.  Please stay with me.  I'm upping the points again.
0
Gandalf32Commented:
OK. I'm looking into it. I'll try to give you some feedback today.
0
Gandalf32Commented:
OK. here goes a try. Change the Open line with:
m_pConnection->Provider = "Microsoft.Jet.OLEDB.3.51";
      m_pConnection->Open("c:\\Koz\\DatabaseTutorial\\SOURCE\\vcdb.mdb","admin","",NULL);
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
koziscoolAuthor Commented:

God only knows how, but that did it.  I'm going to give you credit for the points.  This is such a weird problem, I suspect that I might have to ask more questions about this in the future, and I hope you will continue to be as helpful.

To kpc: thanks for your help as well.  If you'll put in some sort of comment in the database general version of this question, I'll credit you for the points there.
0
koziscoolAuthor Commented:

Thankfully I can at least move on.  The particular problem was so quirky that I'm worried about the robustness of the solution.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C++

From novice to tech pro — start learning today.