1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
| // XMLtoDBF.cpp : Defines the entry point for the console application.
//
#define _AFXDLL
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <afxdb.h>
#include <afxwin.h>
#include <sstream>
#include <io.h>
#include <odbcinst.h>
#include "stdafx.h"
using namespace std;
//global variable
/*
globalTableName - is name of the output file and the table name.
xml_string - is the string without a space, and all elements XML in a line, like
"<without a root><date>10.09.2012</date></root>.
*/
string globalTableName;
string xml_string;
//**********************************************************************************************************************
// The class describes a Row in FoxPro Databases.
class Row
{
public:
void addValue(string data)
{
/*
We get a some xml block, like "<size>60</size>" and We already have the instance of the class,
our class has the table name and the markup, our row type can have the CHAR type, the NUMERIC type, the DATE type,
and make the parsing.
"end" is the keyword, it means a empty row
*/
string::size_type positionBegin;
string::size_type positionEnd;
string::size_type lenghtFirstTag;
string::size_type cutSize;
string unParseStringBegin;
string unParseStringEnd;
unParseStringBegin = "<" + RowName + ">";
unParseStringEnd = "</" + RowName + ">";
positionBegin = data.find(unParseStringBegin);
positionEnd = data.find(unParseStringEnd);
lenghtFirstTag = unParseStringBegin.length();
string year;
string month;
string day;
string tmpString;
if ((positionBegin != string::npos) && ( positionEnd != string::npos) && ((positionBegin + lenghtFirstTag)< positionEnd))
{
++sizeValues;
cutSize = positionEnd - (positionBegin + lenghtFirstTag);
if (RowType == "CHAR")
{
Values.push_back("'" + data.substr(positionBegin + lenghtFirstTag, cutSize)+ "'");
}
if (RowType == "NUMERIC")
{
Values.push_back(data.substr(positionBegin + lenghtFirstTag, cutSize));
}
if (RowType == "DATE")
{
tmpString = data.substr(positionBegin + lenghtFirstTag, cutSize);
year = tmpString.substr(0,4);
tmpString.erase(0,4);
month = tmpString.substr(0,2);
tmpString.erase(0,2);
day = tmpString.substr(0,2);
Values.push_back("{^" + year + "/" + month + "/" + day +"}");
}
}
if ((positionBegin + lenghtFirstTag) == positionEnd)
{
++sizeValues;
Values.push_back("end");
}
}
void setRowName(string name)
{
RowName = name;
}
string getRowName ()
{
return RowName;
}
void setRowTypes(string type)
{
RowType = type;
}
string getRowType()
{
return RowType;
}
void setSizeBeforeDot (int size)
{
SizeBeforeDot = size;
}
void setSizeAfterDot (int size)
{
SizeAfterDot = size;
}
void createRowString()
{
// In this function, We create SQL requests (ALTER TABLE).
TableName = globalTableName;
firstValue = Values.begin();
lastValue = Values.end();
string select;
stringstream strm1;
stringstream strm2;
if ((RowType == "N") || (RowType == "n") || (RowType == "NUMBER") || (RowType == "number") || //for numeric
(RowType == "NUMERIC") || (RowType == "numeric"))
{
strm1 << SizeBeforeDot;
strm2 << SizeAfterDot;
select = "ALTER TABLE " + TableName + " ADD " + RowName + " " + "NUMERIC(" + strm1.str() + "," + strm2.str() + ");";
SQLAlterTable = select;
}
if ((RowType == "char") || (RowType == "CHAR") || (RowType == "TEXT") || (RowType == "text")
|| (RowType == "C") || (RowType == "c")) // for char
{
strm1 << SizeBeforeDot;
select = "ALTER TABLE " + TableName + " ADD " + RowName + " " + "CHAR(" + strm1.str() + ");";
SQLAlterTable = select;
}
if ((RowType == "date") || (RowType == "DATE") || (RowType == "D") || (RowType == "d")) // for date
{
select = "ALTER TABLE " + TableName + " ADD " + RowName + " " + "DATE" +";";
SQLAlterTable = select;
}
}
string getSQLAlterTable()
{
return SQLAlterTable;
}
string getSQLValue()
// This function like a container, returns next value.
{
if (firstValue != lastValue)
{
if (firstValue == Values.begin())
{
string tmpString;
tmpString = *firstValue;
++firstValue;
return tmpString;
}
else
{
if (firstValue != lastValue)
{
string tmpString;
tmpString = *firstValue;
++firstValue;
return tmpString;
}
}
}
else
return "end";
}
int getsizeValues()
{
return sizeValues;
}
void setsizeValues()
{
sizeValues = 0;
}
private:
string TableName;
string RowName;
string RowType;
int SizeBeforeDot;
int SizeAfterDot;
string SQLAlterTable;
vector <string> Values;
int sizeValues; // The number of values in the container.
vector <string>::iterator firstValue;
vector <string>::iterator lastValue;
};
//**********************************************************************************************************************
//**********************************************************************************************************************
// This function parses the table struct and creates a new instance class "Row".
vector <Row> createTableObject (vector <string> dataContainer)
{
int position;
int sizeBeforeDot;
int sizeAfterDot;
vector <string>::iterator begin = dataContainer.begin();
vector <string>::iterator end = dataContainer.end();
vector <Row> parseRow;
string similarType;
while (begin != end)
{
if ((*begin).find(";") != string::npos)
{
Row * tmpRow = new Row();
tmpRow->setsizeValues();
position = (*begin).find(";");
tmpRow->setRowName((*begin).substr(0,position));
(*begin).erase(0, position + 1);
position = (*begin).find(";");
similarType = (*begin).substr(0,position);
if ((similarType == "N") || (similarType == "n") || (similarType == "NUMBER") || (similarType == "number") || //for numeric
(similarType == "NUMERIC") || (similarType == "numeric"))
{
tmpRow->setRowTypes("NUMERIC");
(*begin).erase(0, position + 1);
position = (*begin).find(";");
sizeBeforeDot = atoi((*begin).substr(0,position).c_str());
(*begin).erase(0, position + 1);
sizeAfterDot = atoi((*begin).c_str());
sizeBeforeDot = sizeBeforeDot - sizeAfterDot;
tmpRow->setSizeBeforeDot(sizeBeforeDot);
tmpRow->setSizeAfterDot(sizeAfterDot);
}
if ((similarType == "char") || (similarType == "CHAR") || (similarType == "TEXT") || (similarType == "text")
|| (similarType == "C") || (similarType == "c")) // for char
{
tmpRow->setRowTypes("CHAR");
(*begin).erase(0, position + 1);
position = (*begin).find(";");
sizeBeforeDot = atoi((*begin).substr(0,position).c_str());
(*begin).erase(0, position + 1);
sizeAfterDot = atoi((*begin).c_str());
tmpRow->setSizeBeforeDot(sizeBeforeDot);
tmpRow->setSizeAfterDot(sizeAfterDot);
}
if ((similarType == "date") || (similarType == "DATE") || (similarType == "D") || (similarType == "d")) // for date
{
tmpRow->setRowTypes("DATE");
(*begin).erase(0, position + 1);
position = (*begin).find(";");
sizeBeforeDot = atoi((*begin).substr(0,position).c_str());
(*begin).erase(0, position + 1);
sizeAfterDot = atoi((*begin).c_str());
tmpRow->setSizeBeforeDot(sizeBeforeDot);
tmpRow->setSizeAfterDot(sizeAfterDot);
}
parseRow.push_back(*tmpRow);
}
++begin;
}
return parseRow;
};
//**********************************************************************************************************************
//**********************************************************************************************************************
// The class describes a xml block.
class XML_TREE
{
public :
string name;
string text;
vector <XML_TREE*> Tree;
};
//**********************************************************************************************************************
//**********************************************************************************************************************
/* It is simple xml parser(recursive). If the father's name does not match the name of his son, the recursion,
the son becomes the father, as an argument. If the father's name is the same as the name of his son, then recursively ascends upwards.
If there is a value, then its value is assigned to the recursive level where we are.
*/
void XML_Parse (XML_TREE * height_tree)
{
string::size_type position1;
string::size_type position2;
string::size_type position3;
string::size_type position4;
string levelname("");
while (height_tree->name != levelname)
{
position1 = xml_string.find("<");
position2 = xml_string.find("</");
if ((position1 == 0) && (position2 != position1))
{
string tmpString;
position2 = xml_string.find(">");
tmpString = xml_string.substr(position1 + 1, position2 - (position1 + 1));
xml_string.erase(0, position2 + 1);
XML_TREE * new_XML_TREE = new XML_TREE;
new_XML_TREE->name = tmpString;
height_tree->Tree.push_back(new_XML_TREE);
XML_Parse(new_XML_TREE);
}
if (position1 != 0)
{
height_tree->text = xml_string.substr(0, position1);
xml_string.erase(0, position1);
}
if ((position1 == 0) && (position2 == position1))
{
string tmpString;
position2 = xml_string.find(">");
tmpString = xml_string.substr(position1 + 2, position2 - (position1 + 2));
xml_string.erase(0, position2 + 1);
levelname = tmpString;
}
}
};
//**********************************************************************************************************************
/*
The recursive function that compares the container with pointers to the class "Row",
if the name of XML unit does not match the name of the class, the recursive descent, if not then
xml value in the class function "addValue".
*/
void compareXML_Struct (vector <Row> * createTableObject, XML_TREE * new_XML_TREE)
{
vector <XML_TREE*>::iterator beginXML = new_XML_TREE->Tree.begin();
vector <XML_TREE*>::iterator endXML = new_XML_TREE->Tree.end();
vector <Row>::iterator beginStruct = createTableObject->begin();
vector <Row>::iterator endStruct = createTableObject->end();
if (new_XML_TREE->Tree.size() != 0)
{
while (beginXML != endXML)
{
compareXML_Struct (createTableObject,(*beginXML));
++beginXML;
}
}
else
{
while (beginStruct != endStruct)
{
if (beginStruct->getRowName() == new_XML_TREE->name)
{
beginStruct->addValue("<" + beginStruct->getRowName() + ">" + new_XML_TREE->text + "</" + beginStruct->getRowName() + ">");
string tmpstring;
tmpstring = "<" + beginStruct->getRowName() + ">" + new_XML_TREE->text + "</" + beginStruct->getRowName() + ">";
}
++beginStruct;
}
}
};
//**********************************************************************************************************************
//**********************************************************************************************************************
bool checkPathFile (string path)
{
if (access(path.c_str(), 0) != -1)
{
cout << "The File : " + path + " is available" << endl;
return true;
}
else
{
cout << "The File : " + path + " isn't available" << endl;
cout << "Please press enter to exit" << endl;
return false;
}
};
//**********************************************************************************************************************
//**********************************************************************************************************************
bool checkPathDirectory (string path)
{
if (access(path.c_str(), 0) != -1)
{
cout << "The Directory : " + path + " is available" << endl;
return true;
}
else
{
cout << "The Directory : " + path + " isn't available" << endl;
cout << "Please press enter to exit" << endl;
return false;
}
};
//**********************************************************************************************************************
// Checks output path, and saves name of a output file.
string checkAndParseOutFile (string path)
{
string::size_type positionFileName;
positionFileName = path.find_last_of('\\');
if (positionFileName == string::npos)
{
string::size_type positionPoint;
positionPoint = path.find(".");
globalTableName = path.substr(0,positionPoint);
return "Current Direcory";
}
else
{
++positionFileName;
string FileName(positionFileName, path.length() - positionFileName);
string::size_type positionPoint;
positionPoint = path.find(".");
globalTableName = path.substr(positionFileName,positionPoint - positionFileName);
return path.substr(0,positionFileName - 1);
}
};
int main(int argc, char *argv[])
{
setlocale( LC_ALL,"Russian" );
cout << "XMLtoDBF v 0.90b UkrPay 2012 by Dusheyko " << endl;
// Declaring system paths
// argv[1] - file of structure dbf
// argv[2] - input file
// argv[3] - output file
string NameOfFileStructure;
string NameOfFileXML;
string NameOfOutFile;
string PathOutFile;
NameOfOutFile = argv[3];
NameOfFileStructure = argv[1];
NameOfFileXML = argv[2];
// NameOfOutFile = "D:\\table1.dbf";
// NameOfFileStructure = "OPER.txt";
// NameOfFileXML = "P1210191.aaa";
if (argc != 4)
{
cout << "You entered invalid command-line arguments." << endl;
cout << "Arguments : <file struction> <file xml> <out file *.dbf>";
return -1;
}
if (!checkPathFile(NameOfFileXML))
{
_gettchar();
return -1;
}
if (!checkPathFile(NameOfFileStructure))
{
_gettchar();
return -1;
}
PathOutFile = checkAndParseOutFile(NameOfOutFile);
if (PathOutFile != "Current Direcory")
{
if (!checkPathDirectory(PathOutFile))
{
_gettchar();
return -1;
}
}
//checks for file
string CheckFile("");
char Choise[256];
CheckFile = NameOfOutFile;
if (access(CheckFile.c_str(), 0) != -1)
{
cout << "Do you want rewrite " << CheckFile << endl;
cout << "Y / N :" << endl;
cin.getline (Choise,256);
if (Choise[0] == 'N' || Choise[0] == 'n')
{
cout << "Please save your file to the next start" << endl;
_gettchar();
return 0;
}
}
//Creates the structure
string data;
vector <string> dataContainer;
ifstream infile (NameOfFileStructure);
do
{
infile >> data;
dataContainer.push_back(data);
} while (getline(infile,data));
infile.close();
infile.clear();
vector<Row> TableObject;
TableObject = createTableObject(dataContainer);
// Loads XML without Prolog
infile.open (NameOfFileXML);
string dataXMLinString("");
string::size_type positionProlog;
while (getline(infile,data))
{
positionProlog = data.find("<?");
if (positionProlog != string::npos)
continue;
positionProlog = data.find("<!");
if (positionProlog != string::npos)
continue;
positionProlog = data.find("<!--");
if (positionProlog != string::npos)
continue;
dataXMLinString += data;
}
infile.close();
infile.clear();
// Deletes all attributes in string
string Block("");
string::size_type beginBlock;
string::size_type endBlock;
string::size_type positionSpace;
string::size_type positionAttSpace;
do
{
beginBlock = dataXMLinString.find("<");
endBlock = dataXMLinString.find(">");
if (beginBlock != string::npos)
{
Block = dataXMLinString.substr(beginBlock, (endBlock - beginBlock) + 1);
positionSpace = Block.find(" ");
if (positionSpace != string::npos)
{
string::size_type positionBeginWithSpace = Block.find("< ");
string::size_type positionEndWithSpace = Block.find(" >");
if (positionBeginWithSpace != string::npos)
{
while(positionBeginWithSpace != string::npos)
{
Block.erase(positionBeginWithSpace + 1, 1);
positionBeginWithSpace = Block.find("< ");
}
}
if (positionEndWithSpace != string::npos)
{
while(positionBeginWithSpace != string::npos)
{
Block.erase(positionBeginWithSpace - 1, 1);
positionBeginWithSpace = Block.find(" >");
}
}
positionSpace = Block.find(" ");
if (positionSpace != string::npos)
{
string::iterator MidleString = Block.begin() + positionSpace;
string::iterator EndString = Block.end();
Block.erase (MidleString, EndString);
Block = "``" + Block;
Block = Block + "~~";
}
else
{
Block = "``" + Block;
Block = Block + "~~";
}
}
else
{
Block = "``" + Block;
Block = Block + "~~";
}
beginBlock = Block.find("<");
if (beginBlock != string::npos)
Block.erase(beginBlock, 1);
endBlock = Block.find(">");
if (endBlock != string::npos)
Block.erase(endBlock, 1);
endBlock = dataXMLinString.find(">");
dataXMLinString.insert(endBlock + 1,Block);
beginBlock = dataXMLinString.find("<");
endBlock = dataXMLinString.find(">");
dataXMLinString.erase(beginBlock,(endBlock - beginBlock) + 1);
}
} while (beginBlock != string::npos);
// Changes and Deletes temporary dividers "<" == "``", "<" == "~~"
string::size_type positionDividers;
do
{
positionDividers = dataXMLinString.find("``");
if (positionDividers != string::npos)
{
dataXMLinString.insert(positionDividers + 2,"<");
dataXMLinString.erase(positionDividers, 2);
}
}while (positionDividers != string::npos);
do
{
positionDividers = dataXMLinString.find("~~");
if (positionDividers != string::npos)
{
dataXMLinString.insert(positionDividers + 2,">");
dataXMLinString.erase(positionDividers, 2);
}
}while (positionDividers != string::npos);
// Deletes all space in string
do
{
positionSpace = dataXMLinString.find(" ");
if (positionSpace != string::npos)
dataXMLinString.erase(positionSpace, 1);
}while (positionSpace != string::npos);
//Cretes root XML
string::size_type rootBegin;
string::size_type rootEnd;
rootBegin = dataXMLinString.find("<");
rootEnd = dataXMLinString.find(">");
XML_TREE * new_XML_TREE = new XML_TREE;
new_XML_TREE->name = dataXMLinString.substr(rootBegin + 1, rootEnd - rootBegin - 1);
dataXMLinString.erase(rootBegin, rootEnd + 1);
xml_string = dataXMLinString;
// Executes
XML_Parse(new_XML_TREE);
compareXML_Struct(&TableObject,new_XML_TREE);
//Create SQL in Objects
vector<Row>::iterator begin = TableObject.begin();
vector<Row>::iterator end = TableObject.end();
while (begin != end)
{
begin->createRowString();
++begin;
}
// Get Current Directory path
CString CurrentDirectory;
if (PathOutFile == "Current Direcory")
{
char cwd[1000];
DWORD cwdsz = sizeof(cwd);
int ret = GetCurrentDirectory(cwdsz, cwd);
for (int i = 0; i < ret; i++)
{
if (cwd[i] == '\\')
CurrentDirectory += "\\";
CurrentDirectory += cwd[i];
}
CurrentDirectory = "SourceDB=" + CurrentDirectory + "\\";
}
// Adding an ODBC data source with the SQLConfigDataSource (FoxPro)
char *szDriver = "Microsoft Visual FoxPro Driver";
CString tmpStr;
tmpStr="DSN=NewVFP1\\";
tmpStr+="Description=VFP Data Source\\";
tmpStr+=CurrentDirectory;
tmpStr+="SourceType=DBF\\";
tmpStr+="Collate=Machine\\";
tmpStr+="BackgroundFetch=Yes\\";
tmpStr+="Exclusive=No\\";
char *szAttributes=tmpStr.GetBuffer(tmpStr.GetLength());
for(int i=0;i<tmpStr.GetLength();i++)
{
if(*(szAttributes+i)==(int) '\\')
*(szAttributes+i)=NULL;
}
if (!SQLConfigDataSource(NULL, ODBC_ADD_DSN, szDriver, szAttributes))
{
cout << "Create config ODBC - ERROR" << endl;
}
else
{
cout << "Create config ODBC - OK" << endl;
}
// Makes a connection with the new ODBC driver
CDatabase cdbMyDB;
cdbMyDB.OpenEx("DSN=NewVFP1");
begin = TableObject.begin();
end = TableObject.end();
// Fills the table
string ForCreate;
ForCreate = "CREATE TABLE " + globalTableName + " (test CHAR(20));";
cdbMyDB.ExecuteSQL(ForCreate.c_str());
while (begin != end)
{
cdbMyDB.ExecuteSQL((begin->getSQLAlterTable()).c_str());
++begin;
}
ForCreate = "ALTER TABLE " + globalTableName + " DROP COLUMN test;";
cdbMyDB.ExecuteSQL(ForCreate.c_str());
// Counts the maximum number of rows of columns
int counter(0);
begin = TableObject.begin();
end = TableObject.end();
while (begin != end)
{
if (counter < begin->getsizeValues())
counter = begin->getsizeValues();
++begin;
}
// Creates SQL requests (INSERT) for one line
string SQLInsertColumn("");
string SQLInsertValue("");
string IfIsNullString("");
string SQLExecuteString("");
for (int i = 0; i < counter; i++)
{
begin = TableObject.begin();
end = TableObject.end();
SQLInsertColumn = "";
SQLInsertValue = "";
IfIsNullString ="";
SQLExecuteString = "";
while (begin != end)
{
if ((begin + 1) != end)
{
SQLInsertColumn = SQLInsertColumn + begin->getRowName() + ",";
IfIsNullString = begin->getSQLValue();
if (IfIsNullString != "end")
{
SQLInsertValue = SQLInsertValue + IfIsNullString + ",";
}
else
{
if (begin->getRowType() == "NUMERIC")
SQLInsertValue = SQLInsertValue + "0" + ",";
if (begin->getRowType() == "CHAR")
SQLInsertValue = SQLInsertValue + "''" + ",";
if (begin->getRowType() == "DATE")
SQLInsertValue = SQLInsertValue + "{}" + ",";
}
++begin;
}
else
{
SQLInsertColumn = SQLInsertColumn + begin->getRowName();
IfIsNullString = begin->getSQLValue();
if (IfIsNullString != "end")
{
SQLInsertValue = SQLInsertValue + IfIsNullString;
}
else
{
if (begin->getRowType() == "NUMERIC")
SQLInsertValue = SQLInsertValue + "0";
if (begin->getRowType() == "CHAR")
SQLInsertValue = SQLInsertValue + "''";
if (begin->getRowType() == "DATE")
SQLInsertValue = SQLInsertValue + "{}";
}
++begin;
}
}
SQLExecuteString = "INSERT INTO " + globalTableName + " (" + SQLInsertColumn + ") VALUES (" + SQLInsertValue + ");";
cdbMyDB.ExecuteSQL(SQLExecuteString.c_str());
}
cdbMyDB.Close();
// Copies the new database file in the output path.
if (PathOutFile != "Current Direcory")
{
std::ifstream in (globalTableName + ".dbf"); // open original file
std::ofstream out(NameOfOutFile,std::ios::binary);
out << in.rdbuf();
out.close();
in.close();
}
cout << "All done";
_gettchar();
return 0;
} |