Well, in retrospect, it shouldn't be a surprise that restoring the database doesn't work, either. And there isn't a method on the connection to do that. And I don't know if this helps:
MyConnection.Params.Add('AutoCommit=true');
Because it breaks all the regular transactions.
Holy ***, what a very frustrating database to work with! It is just like something made by Microsoft!
Oh, wait...
Edit: using the autocommit for the restore only doesn't work, either:
databases.Clear;
MyConnection.ExecuteDirect('use ' + MyDatabase);
query.SQL.Text := 'select * from BackupTable order by FileName';
query.Open;
while not query.EOF do
begin
q2.SQL.Text := 'restore database ' + query.FieldByName('DatabaseName').AsString;
q2.SQL.Add('from disk = N''' + query.FieldByName('FileName').AsString + '''');
q2.SQL.Add('with file = 1,');
q2.SQL.Add('move N''' + query.FieldByName('LogicalName').AsString + ''' to ');
q2.SQL.Add('N''' + db +
ExtractFileName(query.FieldByName('PhysicalName').AsString) + ''',');
query.Next;
q2.SQL.Add('move N''' + query.FieldByName('LogicalName').AsString + ''' to ');
q2.SQL.Add('N''' + db +
ExtractFileName(query.FieldByName('PhysicalName').AsString) + ''',');
q2.SQL.Add('nounload,');
q2.SQL.Add('stats = 5');
databases.Add(q2.SQL.Text);
query.Next;
end;
MyConnection.Connected := False;
MyConnection.DatabaseName := 'master';
MyConnection.Params.Add('AutoCommit=true');
for s in databases do
begin
MyConnection.ExecuteDirect(s);
MyConnection.Close;
end;
(There's two records in the BackupTable for each database: one for the .mdf and one for the .ldf. They're from the 'restore headeronly' and 'restore filelistonly' actions.)