This is a migrated thread and some comments may be shown as answers.

data access - stored procedure - restore database error 3013

3 Answers 30 Views
Data Access Free Edition
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
MSu
Top achievements
Rank 2
MSu asked on 03 Aug 2016, 02:18 PM

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

Sort by
0
Kristian Nikolov
Telerik team
answered on 10 Aug 2016, 07:20 AM
Hi Marco,

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
 
Check out the latest announcement about Telerik Data Access vNext as a powerful framework able to solve core development problems.
0
MSu
Top achievements
Rank 2
answered on 10 Aug 2016, 07:43 AM

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);
            }

0
Accepted
Kristian Nikolov
Telerik team
answered on 12 Aug 2016, 12:11 PM
Hello Marco,

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
 
Check out the latest announcement about Telerik Data Access vNext as a powerful framework able to solve core development problems.
Tags
Data Access Free Edition
Asked by
MSu
Top achievements
Rank 2
Answers by
Kristian Nikolov
Telerik team
MSu
Top achievements
Rank 2
Share this question
or