473,385 Members | 1,824 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

how to add new records to a data base by code

i write a small prog with builder c++ 5 that extract lines from text
file then add them into Paradoxe7 table these lines will appear in
a DBGrid on the Form by a click on Button1
the file contains many paragraphs each paragraph has the same end line
"end" , like this ;
line1
line2
line3
...
end
line1
line2
line3
...
end
...
feof
------------------this is my sample code-----------------------
---------------------------------------voici l'exemple de code-----------------------------------------------------
void __fastcall TForm1::FormCreate(TObject *Sender)
{
Table1->Open();
}

FILE*readflot;
char line[80]; /* var used to save each read line */

const char Read_FILE[10]="M.txt"; /* nom du fichier */


void Analyze() /* test if end of paragraph and insert read line into Table1 */
{
if(AnsiStrPos(line,"end")!=NULL)
{
Form1->Table1->Insert();
Form1->Table1->FieldByName("lines")->Value=line;
}

}
void __fastcall TForm1::Button1Click(TObject *Sender)
{
readflot=fopen(Read_FILE,"r"); /*read*/
if (!readflot)
{
Form1->Edit1->Text= "file opening operation's Impossible" ;
}
else /* fichier en lecture accessible */
{

while(!feof(readflot))
{
fgets(line,80,readflot) ;
Analyze();
} /* (feof(readflot)) */
fclose(readflot);
}
}

----------------------end of program------------------------------------------------
anyone can give me the reasen why the debugger send me when i execute then i click on
Button1 "DBEngine ERROR 'key violation' " after it fills one record in DBGrid ?
so my problem is " how to add new records to a data base by code automatiquely "

i tried to make google search but without a result

sorry for my bad english and thanks in advance
Jan 19 '08 #1
0 1161

Sign in to post your reply or Sign up for a free account.

Similar topics

28
by: Act | last post by:
Why is it suggested to not define data members as "protected"? Thanks for help!
28
by: Lee Rouse | last post by:
Hello all, This is going to be a rather lengthy "question". I have an Access 2k database, separated front end/back end. Front end copies are on about 30 workstations and used frequently during...
2
by: M Stery | last post by:
Have two base queries used for mailing labels with id,name,address,city,state,zip that are combined via a union query. One base query uses home address; the other base query uses biz address. I...
1
by: Bob Alston | last post by:
I have a local nonprofit that has a database with a rather unusual record structure. The data about their customers is stored as one value per record. So the access table definition is:...
10
by: Robert | last post by:
How do you get an accurate count of the number of records returned from a query when using linked tables. I have an access 2003 database as a front end to another access 2003 database that...
5
by: Sherry | last post by:
Is there a way to automatically, or by using say a function key, call/paste into a current table or query's field the same value entered for the same field in the immediately preceeding record,...
8
by: hyper-sensitive | last post by:
Hi Can some body suggest me which approach I should follow to import millions of records from data base into an excel sheet? I am working with ver. 2000 of MS-Excel . The requirement is to...
4
by: Claire | last post by:
Hi, I'm writing an internal mail system module for my project. There may be several thousand 'users' on site, and I need the whole list for filtering, so I decided to load up the users in the main...
4
by: Thomas Arthur Seidel | last post by:
Hello to all, I have a small or big problem with a customer data base, where during a change of system we might have created duplicate records. This should be easy to find, you might think, but,...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.