Home » U++ Library support » U++ SQL » how to read a dbf
|
Re: how to read a dbf [message #8200 is a reply to message #8198] |
Sun, 18 February 2007 11:05 |
|
mirek
Messages: 13975 Registered: November 2005
|
Ultimate Member |
|
|
forlano wrote on Sat, 17 February 2007 18:32 | Hello,
I need to read the content of a DBF file.
Is there a code snippet that shows how to get a given row of a DBF file?
The class DbfStream I'm sure can do this silly task easily but I do not know how to use it
Thank you,
Luigi
|
Here is copy&paste of routine that imports .dbf data into Oracle in one of my apps. I hope it helps:
void Eb::Import()
{
...........
FileSel fs;
#ifdef _DEBUG
fs.AllFilesType();
fs.ActiveDir("F:\\DATA");
#endif
if(!fs.ExecuteSelectDir())
return;
DbfStream dbf;
if(!dbf.Open(AppendFileName(~fs, "EI_ZAKL.DBF"))) {
Exclamation("Nelze otevøít ei_zakl.dbf");
return;
}
.........
Progress pi("Importuji %d");
pi.SetTotal(dbf.GetRowCount());
Index<String> nf;
while(dbf.Fetch()) {
if(pi.StepCanceled()) return;
String text;
int osoba_seq = DoOsoba(dbf["RC"], dbf["JMENO"], dbf["PRIJMENI"], dbf["ROD_PRIJM"],
dbf["ULICE"], dbf["POPCIS"], dbf["OBEC"], dbf["MESTO"],
dbf["PSC"]);
if(!IsNull(osoba_seq)) {
int zastupce_seq = Null;
if(!IsNull(dbf["ZASTPRIJM"])) {
zastupce_seq = DoOsoba(dbf["ZAST_RC"], dbf["ZASTJMEN"], dbf["ZASTPRIJM"],
dbf["ZASTROD_PR"], dbf["ZASTULICE"],
dbf["ZASTPOPCIS"], dbf["ZASTOBEC"], dbf["ZASTMESTO"],
dbf["ZASTPSC"]);
if(IsNull(zastupce_seq))
text << "Zástupce nenalezen: "
<< dbf["ZAST_RC"] << ", "
<< dbf["ZASTJMEN"] << " " << dbf["ZASTPRIJM"] << ", "
<< "roz. " << dbf["ZASTROD_PR"] << ", " << dbf["ZASTULICE"]
<< dbf["ZASTPOPCIS"] << ", " << dbf["ZASTOBEC"]
<< " " << dbf["ZASTMESTO"];
}
String t = dbf["POSPR_TYP"];
int stupen = t == "TP" ? 1 : t == "ZTP" ? 2 : t == "ZTP/P" ? 3 : 0;
String cz = dbf["CISVOZIK"];
SQL * Insert(SOCI_INVALIDA)
(SOCI_INVALIDA_SEQ, ++SeqSoci)
(OSOBA_SEQ, osoba_seq)
(COP, dbf["OBCPRUK"])
(DATZAD, dbf["DATZADOST"])
(ZASTUPCE_OSOBA_SEQ, zastupce_seq)
(ZASTUPCE_COP, dbf["ZASTPRUK"])
(DATUM, dbf["DATPRUKOD"])
(DATUM_DO, dbf["DATPRUKDO"])
(CISLO, dbf["POSPR_CIS"])
(STUPEN, stupen)
(ZNACENI, cz)
(DRUH, toupper(cz[0]) == 'A' ? 1 : 2)
(TELEFON, dbf["TELEF"])
(TEXT, text)
;
...........
[Updated on: Sun, 18 February 2007 11:07] Report message to a moderator
|
|
|
|
|
|
|
|
|
Goto Forum:
Current Time: Fri May 03 07:53:37 CEST 2024
Total time taken to generate the page: 0.03357 seconds
|