Re: why cant I get data from the ACCESS

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: Tim (Tim_at_NoSpam)
Date: 02/19/04


Date: Thu, 19 Feb 2004 18:56:34 +1300

Steven,

>From what you are saying I think you need the path to the database in the
connection string along these lines - note this is an ODBC connection
string, not an ADO one, so amend it to use the details you were using:

CString strDSN;
  strDSN.Format(_T("PROVIDER=MSDASQL;DRIVER={Microsoft Access Driver
(*.mdb)};DBQ=%s;"),
     strDBPath);

IE from your code:

CString strDSN;
strDSN.Format(_T("Provider=Microsoft.Jet.OLEDB.4.0;DataSource=%s;"),
strDBPath);

_connectionPtr->Open(strDSN,"","",adModeUnknown)

where strDBPath is the full path to the file EG "c:\My Databases\xx.mdb".

It would be prudent also to wrap your database calls in try / catch handlers
with e->ReportError(); so that you can see what the error messages are.

In ODBC with CDatabase it would be like this:

try
{
    m_db.OpenEx(strDSN);
}
catch(CDBException* e)
{
e->ReportError();
e->Delete();
}

The exception types for ADO are not CDBException.

- Tim

"Steven_chaoxiang" <anonymous@discussions.microsoft.com> wrote in message
news:6DA9F1FA-E6E1-4940-A333-E6CCE7E82704@microsoft.com...
> Hello,everyone:
> I have got a question in MFC, the function of my application is that I
will get data from the ACCESS.My client's damand is that before i get the
data, a dialogbox(CFileDialog used) must be show first in order to save the
file clients input.I use the Cfiledialog.DoModel() to show the dialogbox for
client to save the path of file. However if the path of the file client
input is not at the same catalog as the place where .mdb is ,when you get
the data from the Access using
_connectionPtr->Open("Provider=Microsoft.Jet.OLEDB.4.0;DataSource=xx.mdb",""
,"",adModeUnknown), a excepion will be thrown. I am totally at loss as to
what is wrong with it. To my surprise, if you save the path of the file at
the same catalog as the catalog where xx.mdb is,the applictaion is totally
ok.I wonder who knows the solution to the problem,if someone knows ,please
send the answer to this discussion or send E-mail to me(zlx0615@sina.com.cn)
as quickly as possible,thank you ever so much!!!



Relevant Pages

  • Re: DSN Behaving Badly
    ... With ADO, you can have either a global connection string, global command ... your application which use data from the sql server. ... With ADO, you would still have tbl1, but it would be a local table (for ...
    (comp.databases.ms-access)
  • Re: Working program gives problemm at clients site error:provider not found
    ... Project referrence: ADO 2.8 Library ... Connection string - ... if run source code through vb6, it says missing ADO 2.8 library. ... Have the clients download and install the FoxPro Provider ...
    (microsoft.public.vb.general.discussion)
  • Re: Need example of using ADO DataControl and DataGrid control - V
    ... MSDN is where I learnt ADO. ... Access SDK - Microsoft ActiveX Data Objects - ADO Programmers reference - ... ' Used to build the connection string & SQL string ... ' Set up the recordset. ...
    (microsoft.public.vb.database.ado)
  • Re: Data form wizard error Unrecognized database format
    ... You are attempting to use a mis-matched Jet engine for the format ... A specific fix will vary depending on the versions of the data controls, ... Using ADO 2.5 is bit ancient. ... a quick and easy way to create and test a connection string for use ...
    (microsoft.public.vb.database)
  • Re: Loads of errors when querying MS SQL Server Express 2005 from Access 2007
    ... The problem is with the ODBC connection - in general. ... to be using Access as a front end for a Sql Server backend - you will ... have more consistent/better results using ADO instead of ODBC. ... an ADO datapull from the server, and then you can query that. ...
    (comp.databases.ms-access)