Click here to Skip to main content
16,005,121 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: May I Ask? Pin
Cedric Moonen7-Jan-04 23:34
Cedric Moonen7-Jan-04 23:34 
GeneralRe: May I Ask? Pin
skylonely7-Jan-04 23:54
skylonely7-Jan-04 23:54 
QuestionHow can I access to files with .DBF extension ? Pin
Qadddd7-Jan-04 22:51
Qadddd7-Jan-04 22:51 
AnswerRe: How can I access to files with .DBF extension ? Pin
BadJerry8-Jan-04 0:03
BadJerry8-Jan-04 0:03 
GeneralRe: How can I access to files with .DBF extension ? Pin
Qadddd8-Jan-04 3:20
Qadddd8-Jan-04 3:20 
GeneralRe: How can I access to files with .DBF extension ? Pin
BadJerry8-Jan-04 3:28
BadJerry8-Jan-04 3:28 
GeneralRe: How can I access to files with .DBF extension ? Pin
Qadddd8-Jan-04 3:46
Qadddd8-Jan-04 3:46 
GeneralRe: How can I access to files with .DBF extension ? Pin
Qadddd8-Jan-04 13:53
Qadddd8-Jan-04 13:53 
Hello,

I use the ODBC driver "dBase Files" installed by microsoft.
hereunder is the code I wrote to access the C:\Documents and Settings\dd\Mes documents\GSTAT.DBF file :

#define DBName "DSN=dBASE Files;UID=;PWD:"
...
CDatabase gDB;
CRecordset rs(&gDB);
CString res;
CString ErrMsg;
CString CASHT;
CString NETROOM;
CString DATUM;
int NbRecord;
CString Path = "C:\\Documents and Settings\\dd\\Mes documents\\" ;
CString File = "GSTAT.DBF" ;
ErrMsg = "";
res = "SELECT DATUM,CASHT,NETROOM from ["+File+"]";
// res = "SELECT DATUM,CASHT,NETROOM from ["+File+"] WHERE (DATUM = 20010208)";
// res = "SELECT DATUM,CASHT,NETROOM from ["+File+"] WHERE (DATUM = '20010208')";
// gDB.OpenEx(DBName,CDatabase::noOdbcDialog);
gDB.OpenEx(DBName,CDatabase::forceOdbcDialog );
TRY
{
rs.Open( CRecordset::forwardOnly, res );
NbRecord = rs.GetRecordCount();
}
CATCH(CDBException, e)
{
ErrMsg ="**ERR: "+e->m_strError.Left(70);
}
END_CATCH
if (ErrMsg == "") {
while(!rs.IsEOF()) {
rs.GetFieldValue( "DATUM", DATUM);
rs.GetFieldValue( "CASHT", CASHT);
rs.GetFieldValue( "NETROOM", NETROOM);
rs.MoveNext();
}
}
rs.Close();
gDB.Close();

Used like this, it works but I have some problems :

1) I am obliged go thru the ODBC display to give the name of the file, I can't set it by program ... why ? How can I do this and use the noOdbcDialog option (When I try to use it, ODBC tells me that it can't find GSTAT.DBF)?
Furthermore, ODBC dialog is based on program directory, not on the path. If I add the Path to the name in File variable, ODBC tells me that it can't find C:\Documents and Settings\dd\Mes documents\GSTAT.DBF ...
2) If I add the clause "WHERE" to my request, no record is returned ... why ? Can't I use it ? Am I obliged to read all records and test the DATUM field by program ?
3) what is the format of the date in the file ? Excel says 08/02/2001, Word says 20010208 and DATUM = 2001-02-06 when debugging my code ... When I use a date in format yyyy-mm-dd or dd/mm/yyyy ODBC tells me that my format is not compatible

Thanks in advance
DD
GeneralRe: How can I access to files with .DBF extension ? Pin
BadJerry8-Jan-04 22:36
BadJerry8-Jan-04 22:36 
GeneralRe: How can I access to files with .DBF extension ? Pin
Qadddd8-Jan-04 23:35
Qadddd8-Jan-04 23:35 
GeneralRe: How can I access to files with .DBF extension ? Pin
BadJerry9-Jan-04 0:10
BadJerry9-Jan-04 0:10 
GeneralRe: How can I access to files with .DBF extension ? Pin
Qadddd9-Jan-04 4:28
Qadddd9-Jan-04 4:28 
GeneralRe: How can I access to files with .DBF extension ? Pin
BadJerry9-Jan-04 4:40
BadJerry9-Jan-04 4:40 
GeneralRe: How can I access to files with .DBF extension ? Pin
Qadddd9-Jan-04 4:58
Qadddd9-Jan-04 4:58 
GeneralRe: How can I access to files with .DBF extension ? Pin
BadJerry9-Jan-04 5:40
BadJerry9-Jan-04 5:40 
GeneralRe: How can I access to files with .DBF extension ? Pin
Qadddd17-Jan-04 23:55
Qadddd17-Jan-04 23:55 
GeneralPrecompiled headers Pin
Patje7-Jan-04 22:49
Patje7-Jan-04 22:49 
Generalneed help Pin
sls0077-Jan-04 22:48
sls0077-Jan-04 22:48 
GeneralRe: need help Pin
Antti Keskinen8-Jan-04 0:16
Antti Keskinen8-Jan-04 0:16 
QuestionHow to create patch for program update? Pin
Ming Yan7-Jan-04 21:31
Ming Yan7-Jan-04 21:31 
AnswerRe: How to create patch for program update? Pin
Antti Keskinen7-Jan-04 21:38
Antti Keskinen7-Jan-04 21:38 
GeneralRe: How to create patch for program update? Pin
Ming Yan7-Jan-04 22:21
Ming Yan7-Jan-04 22:21 
GeneralRe: How to create patch for program update? Pin
Antti Keskinen8-Jan-04 0:11
Antti Keskinen8-Jan-04 0:11 
GeneralRe: How to create patch for program update? Pin
Ming Yan8-Jan-04 14:52
Ming Yan8-Jan-04 14:52 
Generalcreating toolbar window(MFC) Pin
grunt1237-Jan-04 21:08
grunt1237-Jan-04 21:08 

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.