Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Importing Data from txt file to DB

Status
Not open for further replies.

minckle

Programmer
Mar 17, 2004
142
GB
Im writing an application using Delphi 5 and MySQL backend. The application deals with customer contact details. I want a function so the customer can import a file of contacts into the DB.
Seperately,I can use the MySQLImport function via command prompt and it imports the file OK, below

C:\mysql\bin\mysqlimport -u UserName -pPassword --local --columns client_id,forename,surname,mob_number --fields-terminated-by=, --lines-terminated-by=\r\n itextit c:\contact.txt

but, how do i go about running it via delphi, is there a way to run the above from the command prompt using delphi?????

Hope you understand what im trying to do

Any Help or advice appreciated

 
Look at the WinExec function. We've used it something like this:
Code:
  CmdFile := '"' + UpdateSourceDir + 'AutoUpdate.exe"';
  CmdParm := '/U="' + DirToUpdate + '" ' +
    '/S="' + UpdateSourceDir + '" ' +
    '/P="' + ApplicationToStartWhenFinished + '" ' +
    '/A="' + UpdateFile + '"';
  RetVal := WinExec(PChar(CmdFile + ' ' + CmdParm), SW_SHOW);
  Result := RetVal > 32;
  if not Result then
  begin
    ShellApiError(RetVal);
  end;

-Dell
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top