Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 3 of 3 total
Thread Problem with SQL String Generated from Code
Tue, Jul 24 2007 5:58 AMPermanent Link

Peter Thorne
Sorry it's me again.

I have been trying the following code:

 with qryImpEx do
 begin
   BackupName := ChangeFileExt(ExtractFileName(FileName), '');
   BackupDir := ExtractFileDir(FileName);
   SQLString := 'BACKUP DATABASE ExtrapolateIE' + ' AS ' + engExtrapolate.QuotedSQLStr(BackupName)
                + ' TO ' + engExtrapolate.QuotedSQLStr(BackupDir) + ' INCLUDE CATALOG';
   SQL.Clear;
   SQL.Add(SQLString);
   Prepare;
   ExecSQL;
 end

To generate (for example):

'BACKUP DATABASE ExtrapolateIE AS 'TestExport' TO 'C:\Documents and Settings\Owner\Desktop' INCLUDE CATALOG'

as the SQL string.

This is throwing a 700 error at runtime (Expected backup name but instead found 'TestExport'). What am I doing wrong?

Peter
Tue, Jul 24 2007 6:16 AMPermanent Link

Peter Thorne
OK. I've kind of sussed this running the query statically. It looks like you need double quotes for the backup name and single quotes for the backup directory (seems a bit wierd?)
Tue, Jul 24 2007 4:12 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Peter,

<< OK. I've kind of sussed this running the query statically. It looks like
you need double quotes for the backup name and single quotes for the backup
directory (seems a bit wierd?)  >>

The backup name is considered an identifier and the backup directory is a
constant.  The reason for this is that the backup name must follow
identifier naming rules due to the fact that it shows up in the
configuration database:

http://www.elevatesoft.com/edb1sql_backups_table.htm

--
Tim Young
Elevate Software
www.elevatesoft.com

Image