Solved

Include sql text files into resource of Delphi XE project at compile time

Posted on 2013-01-11
3
1,969 Views
Last Modified: 2013-01-11
I need help figuring out how to include text files into my Delphi XE Project, into the EXE file. The text files are actually sql files that can look like this:
declare @a int set @a=5
declare @b int set @b=2
/*--*/
select @a + @b as sum

Open in new window

I use this format because this .sql file can be opened in MS SQL Server Management Studio, to be edited and tested there.
I want to be able to save the file, and compile the Delphi XE Project and run the program. I want the Delphi XE to read the .sql file into the EXE at compile time. At run time, the program will read out the .sql file, remove whatever is above "/*--*/" and replace all '@' with ':', so that parameters can be supplied in an TADOQuery.

I'm hoping maybe to use resource files to do this. RC files? If that will work, how to compile it into .RES file and include into .EXE at project compile time?
0
Comment
Question by:lefodnes
  • 2
3 Comments
 
LVL 19

Accepted Solution

by:
Thommy earned 500 total points
Comment Utility
0
 
LVL 19

Expert Comment

by:Thommy
Comment Utility
0
 

Author Closing Comment

by:lefodnes
Comment Utility
Thanks Thommy. Good links.
For the use with TADOParameter, I wrote the .sql files like this:

declare int @a set @a = /*:a*/1
declare int @b set @b = /*:b*/2

select @a+@b as sum

Open in new window



In Delphi code, I need to take away comments on the declare lines and remove all after the last "*/", before putting the SQL into TADOQuery, and adding parameters. If colon-parameters are used more than once, they have to be added multiple times. Refer to : http://stackoverflow.com/questions/7613832/how-do-i-use-tadoquery-parameters-with-integer-parameter-types-that-have-to-be-p
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
FMX enumerated colours 2 70
Intraweb download file link ? 1 87
Delphi Form ownership 4 50
Delphi: Connect to running MS Outlook 4 26
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
THe viewer will learn how to use NetBeans IDE 8.0 for Windows to perform CRUD operations on a MySql database.

763 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now