我用的DirectoryListBox1控件,但在ADOCommand1中写sql语句时怎么写啊,选中DirectoryListBox1中的内容该如何显示啊,
BACKUP  DATABASE  DataBaseName  TO  DISK  =  '  +  #39  +  ?????+  #39;  

解决方案 »

  1.   

    if not DirectoryExists('D:\BakSql') then
          if not CreateDir('D:\BakSql') then
             raise Exception.Create('Cannot create D:\BakSql');
       Label1.Caption := '正在进行数据库备份,请等待...';
       DM.bakADOQuery.Close;
       DM.bakADOQuery.SQL.Clear;
       DM.bakADOQuery.SQL.Add('backup database BaoYuan to DISK='+''''+'D:\BakSql\BY'+DateToStr(Date())+'.bak'+''''+' With noinit');
       DM.bakADOQuery.Prepared;
       showmessage(DM.bakADOQuery.SQL.Text);
       DM.bakADOQuery.ExecSQL;
       Label1.Caption := '数据库备份已经完成,谢谢合作!';
      

  2.   

    procedure TbakForm.SpeedButton1Click(Sender: TObject);
    begin
       Label1.Caption := '正在进行数据库备份';
       DM.bakADOQuery.Close;
       DM.bakADOQuery.SQL.Clear;
       DM.bakADOQuery.SQL.Add('backup database TianYe to DISK='+''''+DriveComboBox1.Drive+':\');
       DM.bakADOQuery.SQL.Add(DateToStr(Date())+'.bak'+''''+' With noinit');
       ShowMessage('数据库已经备份到磁盘'+DriveComboBox1.Drive+'的根目录了');
       DM.bakADOQuery.Prepared;
       DM.bakADOQuery.ExecSQL;
       Label1.Caption := '数据库备份完成,谢谢合作';
    end;
      

  3.   

    query.SQL.Add('backup database BaoYuan to DISK=''' + DirectoryListBox1.text+'aaa.bak''');