Solved

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

Posted on 2013-01-11
3
2,105 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
[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
  • 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
Programmer's Notepad is, one of the best free text editing tools available, simply because the developers appear to have second-guessed every weird problem or issue a programmer is likely to run into. One of these problems is selecting and deleti…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.

739 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