Steve wrote:
> I use this command to backup my MSSQL Database
>
> Var Ch:= Char(39);
Another way of writing that is
Ch := #39;
> St1:=DateToStr(Date);Delete(st1,3,1);Delete(st1,5,1);
>
> St2:=TimeToStr(Time);Delete(st2,3,1);Delete(st2,5,1);
Since DateToStr and TimeToStr are sensitive to the user's current locale
settings, I recommend that if you want a format without any punctuation,
you explicitly tell Delphi what format you want. You can do that with
the FormatDateTime function.
It looks like the format you want would come from this:
st := 'Hermes.' + FormatDateTime('yyyymmdd.hhnnss', Now) + '.bak';
That also has the advantage that you fetch the current time all at once
instead of in separate calls. When you get them separately, you risk
that the date will change before you get the time. At just before
midnight, you might get the date, and then you can get the time just
after midnight, at which point you have a date-time combination about 24
hours away from what you wanted.
> st:='Hermes.'+St1+'.'+St2+'.bak';
>
> st:=BackUpPath+'\'+st;st1:=Char(39);
>
> s:='Backup Database Hermes to disk='+ch+st+ch+' with INIT';
>
> Then put the variable s into your routine that you use for commands
Note that the apostrophe character is a perfectly valid file-name
character. It might occur in your BackUpPath variable. It also has
special meaning in SQL. If you want to quote a string for use in SQL,
use the AnsiQuotedStr function to quote it. It will automatically handle
apostrophes that are already in the input string.
Better yet, use a parameterized query and let the database code figure
out how to format the parameters for its own dialect of SQL.
--
Rob
-----------------------------------------------------
Home page: http://groups.yahoo.com/group/delphi-en/
To unsubscribe: [EMAIL PROTECTED]
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/delphi-en/
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/