data access - stored procedure - restore database error 3013

4 posts, 1 answers
  1. Marco
    Marco avatar
    11 posts
    Member since:
    Jan 2014

    Posted 03 Aug Link to this post

    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

  2. Kristian Nikolov
    Admin
    Kristian Nikolov avatar
    206 posts

    Posted 10 Aug Link to this post

    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.
  3. DevCraft banner
  4. Marco
    Marco avatar
    11 posts
    Member since:
    Jan 2014

    Posted 10 Aug in reply to Kristian Nikolov Link to this post

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

  5. Answer
    Kristian Nikolov
    Admin
    Kristian Nikolov avatar
    206 posts

    Posted 12 Aug Link to this post

    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.
Back to Top