Solved

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

Posted on 2013-01-11
3
2,058 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
ID: 38767009
0
 
LVL 19

Expert Comment

by:Thommy
ID: 38767029
0
 

Author Closing Comment

by:lefodnes
ID: 38767134
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.
The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.

832 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