Login ProductsSalesSupportDownloadsAbout |
Home » Technical Support » ElevateDB Technical Support » Support Forums » ElevateDB General » View Thread |
Messages 1 to 5 of 5 total |
How to build database dynamically using code? |
Tue, Oct 2 2007 12:28 PM | Permanent Link |
Dave Harrison | I'm trying to build an EDB database using Delphi code and I'm stuck.
When I run my "Create Database 'abc' path 'c:\test1\data' description ...." it complains 'Database name is missing'. So I assume it is complaining that the TEDBQuery isn't pointing to a database component. So I set the TEDBQuery.DatabaseName := 'MyDatabase'; and the database component points to the directory where the new database will be created. When I run it, it complains the database "c:\test1\data" does not exist, this is the directory the database is suppose to be created in. So it appears it wants to point to the database before it is created. Did I create a paradox here? (Sorry, couldn't resist) Can anyone show me the code needed to create a database? TIA Dave |
Tue, Oct 2 2007 12:50 PM | Permanent Link |
"J. B. Ferguson" | Dave,
Did you check the code in the "CD Collector" example application. Posted below is code from the DataModule OnCreate event, which does what you need to do: begin { Activate the engine. The engine can also be referenced by the generic Engine variable in the edbcomps unit } CDCollectorEngine.Active:=True; { Now connect the session } CDCollectorSession.Connected:=True; { Check to see if the database exists or whether it needs to be created } with ConfigurationQuery do begin SQL.Text:='SELECT * FROM Databases WHERE Name='+Engine.QuotedSQLStr('CDCollector'); Open; if (RecordCount=0) then begin { Database doesn't exist and we need to create it } Close; SQL.Text:='CREATE DATABASE "CDCollector" PATH '+ Engine.QuotedSQLStr(ExtractFilePath(Application.ExeName)+'data'); ExecSQL; end else Close; end; HTH... -- Regards, Jan Ferguson Dave Harrison wrote: <<I'm trying to build an EDB database using Delphi code and I'm stuck. <<When I run my "Create Database 'abc' path 'c:\test1\data' description <<..." it complains 'Database name is missing'. << <<So I assume it is complaining that the TEDBQuery isn't pointing to a <<database component. So I set the TEDBQuery.DatabaseName := <<'MyDatabase'; and the database component points to the directory <<where the new database will be created. When I run it, it complains <<the database "c:\test1\data" does not exist, this is the directory <<the database is suppose to be created in. << <<So it appears it wants to point to the database before it is created. <<Did I create a paradox here? (Sorry, couldn't resist) << <<Can anyone show me the code needed to create a database? TIA |
Tue, Oct 2 2007 1:26 PM | Permanent Link |
Roy Lambert NLH Associates Team Elevate | Dave
>So it appears it wants to point to the database before it is created. >Did I create a paradox here? (Sorry, couldn't resist) Nah! You're just trying to point to the wrong thing. A "database" in this sense is simply an entry in the configuration database so you need to point at that. |
Tue, Oct 2 2007 4:21 PM | Permanent Link |
Dave Harrison | Roy Lambert wrote:
> Dave > > > >>So it appears it wants to point to the database before it is created. >>Did I create a paradox here? (Sorry, couldn't resist) > > > Nah! You're just trying to point to the wrong thing. A "database" in this sense is simply an entry in the configuration database so you need to point at that. > So I'm not going bonkers after all? I didn't realize there was a Configuration database. I followed Jan's advice and looked at the CD Demo and this cleared things up. Dave |
Wed, Oct 3 2007 3:10 AM | Permanent Link |
Roy Lambert NLH Associates Team Elevate | Dave
Yeah I saw his post so thought I'd just add a bit of "clarification" Its worth looking at what is held in the system tables - there's lots of useful stuff in there. I can't remember the heading in the OLH and can't check until HP repair centre finally return my notebook. Roy Lambert |
This web page was last updated on Saturday, April 27, 2024 at 08:52 PM | Privacy PolicySite Map © 2024 Elevate Software, Inc. All Rights Reserved Questions or comments ? E-mail us at info@elevatesoft.com |