In a stored procedure I have have a restore sql command. If I execute this procedure directly from sql server, it works fine.
If I execute the stored procedure from my application over data access, I get an error 3013.
Is this a permission issue? Any ideas?
I hope someone can help me.
Regards, Marco
3 Answers, 1 is accepted
Thank you for contacting us.
In order to help you with troubleshooting the behavior you are experiencing, we would need some additional information:
- Are you using Microsoft SQL Server or another database engine?
- Please send us the stored procedure you are using.
- Please send us the code you are using to call the stored procedure in your application.
This should allow us to gain better understanding of your scenario.
We are looking forward to your feedback.
Regards,
Kristian Nikolov
Telerik by Progress
I'm using Microsoft SQL Server
Stored Procedure:
ALTER procedure [dbo].[CreateNewProjectDatabase]
@ProjectName varchar(100),
@ProjectDescription varchar(500),
@FK_TypicalArt int,
@FK_KommTypicalArt int
as
begin
set nocount on
begin try
-- Create Database from a Template
declare @backupFile varchar(100) = 'D:\Entwicklung\EngProjectTemplate.bak'
declare @moveFrom varchar(100) = 'EngProjectTemplate'
declare @moveFromLog varchar(100) = 'EngProjectTemplate_log'
declare @moveTo varchar(100) = 'C:\Program Files\Microsoft SQL Server\MSSQL12.MSSQLSERVER\MSSQL\DATA\' + @ProjectName + '.mdf'
declare @moveToLog varchar(100) = 'C:\Program Files\Microsoft SQL Server\MSSQL12.MSSQLSERVER\MSSQL\DATA\' + @ProjectName + '_log.ldf'
restore database @ProjectName
from disk = @backupFile
with
file = 1,
move @moveFrom to @moveTo,
move @moveFromLog to @moveToLog,
nounload, stats = 5
end try
begin catch
return @@error
end catch
end else begin
return -1
end
return 0
end
C# Code:
try
{
contextSystem.CreateNewProjectDatabase(tbProjektName.Text, radTextBoxBeschreibung.Text,
(int)radDropDownListTypicalArt.SelectedValue,
(int)radDropDownListKommTypicalArt.SelectedValue,
out retValue);
if (retValue == 0)
{
contextSystem.SaveChanges();
}
else
{
RadMessageBox.Show("SQL Fehler " + retValue, "Fehler", MessageBoxButtons.OK, RadMessageIcon.Error);
}
}
catch (Exception ex)
{
RadMessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, RadMessageIcon.Error);
}
It is very that the issue you are experiencing occurs because the restore operation cannot be performed in a transaction and Telerik Data Access always performs database operations in transactions. For this reason you would not be able to execute this command through Telerik Data Access. Therefore we would suggest you try to use the native ADO.Net API in order to execute your stored procedure.
I hope this helps. Feel free to get back to us if you have more Telerik Data Access questions.
Regards,
Kristian Nikolov
Telerik by Progress