Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Creating database

Posted on 2004-09-24
4
Medium Priority
?
134 Views
Last Modified: 2010-04-05
Hi,

Anyone can show me a way how to create Microsoft Aceess database, .mdb file using Delphi code ?

Thanks
0
Comment
Question by:kapot
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
4 Comments
 
LVL 12

Expert Comment

by:esoftbg
ID: 12141970
download a tested example from :
page:        http://www.geocities.com/esoftbg/
  link:        Q_21090790.zip

Emil
0
 
LVL 12

Expert Comment

by:esoftbg
ID: 12141989
procedure TForm1.FormCreate(Sender: TObject);
var
  I:      Integer;
  FN:     string;
  V:      Variant;
  SLTab:  TStringList;
  SLPro:  TStringList;
begin
  FN := ExtractFilePath(Application.ExeName) + 'DATABASE.MDB';
  ConnStr := 'Data Source=' + FN + ';Provider=Microsoft.Jet.OLEDB.4.0';
  if not FileExists(FN) then
  begin
    V := CreateOleObject('ADOX.Catalog');
    V.Create(ConnStr); // Create Database
  end;
  try
    ADOConnection.Close;
    ADOConnection.ConnectionString := ConnStr;
    ADOConnection.Open;

    SLPro := TStringList.Create;
    try
      Memo.Clear;
      AdoConnection.GetProcedureNames(SLPro);
      if (SLPro.IndexOf('PROC_CREATE_WAARDEBONNEN')<0) then
      begin
        ADOCommand.Connection := AdoConnection;
        ADOCommand.CommandText :=' create procedure PROC_CREATE_WAARDEBONNEN as'
                               + ' create table WAARDEBONNEN ('
                               + ' ID AUTOINCREMENT PRIMARY KEY,'
                               + ' GELDIGHEIDSDATUM DATE,'
                               + ' STATUS TEXT(16)'
                               + ')';
        ADOCommand.Execute;
      end;
    finally
      for I := 0 to SLPro.Count-1 do
        Memo.Lines.Add(SLPro.Strings[I]);
      SLPro.Free;
    end;
    SLTab := TStringList.Create;
    try
      AdoConnection.GetTableNames(SLTab);
      if (SLTab.IndexOf('WAARDEBONNEN')<0) then
      begin
        ADOStoredProc.Connection := AdoConnection;
        ADOStoredProc.ProcedureName := 'PROC_CREATE_WAARDEBONNEN';
        ADOStoredProc.ExecProc;
      end;
    finally
      for I := 0 to SLTab.Count-1 do
        Memo.Lines.Add(SLTab.Strings[I]);
      SLTab.Free;
    end;
  finally
    ADOQueryCHANGES.Connection := AdoConnection;
    ADOQueryCHANGES.Active := True;
    ADOQueryCHANGES.FieldByName('ID').Visible := False;
    for I := 1 to 12 do
      cbxMonths.Items.AddObject(ShortMonthNames[I], TObject(I));
    cbxMonths.ItemIndex := Calendar.Month - 1;
    speYear.Value := Calendar.Year;
  end;
end;
0
 
LVL 12

Accepted Solution

by:
esoftbg earned 435 total points
ID: 12267304
Hi kapot,
I posted two answers about your question:
 - 14 minutes after you posted this question I offered a link to a working example;
 -   3 minutes later I posted a piece of code from working example (from the link).

Today 15 days later I would like to know:
  - Have you any problems, can I help you ? I could to change the example if you need it ....

Best regards,
Emil.
0
 
LVL 12

Expert Comment

by:esoftbg
ID: 12635423
I am very surprised !
Here is not only example of how to create a Database, but how to create a Table inside it !
But you grade my solution with B ???? (Almost two months later ....)
That's a big joke, isn't it ?
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Suggested Courses

604 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question