issue on restore database

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
tonvoo
Posts: 4
Joined: Wed 03 Apr 2019 02:41

issue on restore database

Post by tonvoo » Wed 03 Apr 2019 03:03

Hello,

I' one of your customer from China and I'm use your UniDac for mssql via ODBC.
I found a issue when i use unidac to restore a database, the database will stay in the state : Restoring
But if i use the sql command from ADO, it works fine.
The command is just:
restore database ISMS_Base from disk = 'D:\190402_ISMS_Linux_Dev.bak' with replace
I tracked the command being executed ,the UniDac Actually executed the command :
declare @p1 int
set @p1=5
exec sp_prepare @p1 output,NULL,N'restore database ISMS_Base from disk = ''D:\ISMS_Base20170908.bak'' with replace',1
select @p1
But the ADO execute the :
restore database ISMS_Base from disk = 'D:\190402_ISMS_Linux_Dev.bak' with replace
So i want to just execute the command itself, i don't want to the command prepare.

Thanks !

Stellar
Devart Team
Posts: 304
Joined: Tue 03 Oct 2017 11:00

Re: issue on restore database

Post by Stellar » Thu 04 Apr 2019 15:18

By default, UniDAC doesn’t prepare a query before executing it. Most probably, the AutoPrepare property is set to ‘true’ for TUniQuery. In this mode, UniDAC automatically calls the Prepare method before exewcuting a query. For example:

Code: Select all

UniQuery1.Options.AutoPrepare := False;
UniQuery1.SQL.Text := 'restore database ISMS_Base from disk = ''D:\190402_ISMS_Linux_Dev.bak'' with replace';
UniQuery1.ExecSQL;
Learn more about the AutoPrepare option:
https://www.devart.com/unidac/docs/deva ... repare.htm

UniDAC also allows you to work with SQL Server directly without using the ODBC drivers.

Using SQL Server data access provider with UniDAC in Delphi:
https://www.devart.com/unidac/docs/using-sqlserver.htm

tonvoo
Posts: 4
Joined: Wed 03 Apr 2019 02:41

Re: issue on restore database

Post by tonvoo » Wed 17 Apr 2019 14:19

Thanks very much.

And I find the ODBC prepares the sql clause.

When i use the mssql provider link to SQL Server directly, it works well.

Stellar
Devart Team
Posts: 304
Joined: Tue 03 Oct 2017 11:00

Re: issue on restore database

Post by Stellar » Thu 18 Apr 2019 09:32

Glad to see that the issue was resolved.
Feel free to contact us if you have any further questions about our products.

Post Reply