Click here to Skip to main content
15,880,972 members
Home / Discussions / C#
   

C#

 
GeneralRe: Loosley Coupled Events Pin
SledgeHammer015-Sep-12 12:23
SledgeHammer015-Sep-12 12:23 
GeneralRe: Loosley Coupled Events Pin
Member 81371055-Sep-12 12:51
Member 81371055-Sep-12 12:51 
GeneralRe: Loosley Coupled Events Pin
Member 81371056-Sep-12 6:50
Member 81371056-Sep-12 6:50 
Questionproblem executing console application Pin
dcof5-Sep-12 9:21
dcof5-Sep-12 9:21 
AnswerRe: problem executing console application PinPopular
Pete O'Hanlon5-Sep-12 9:28
mvePete O'Hanlon5-Sep-12 9:28 
GeneralRe: problem executing console application Pin
Wes Aday5-Sep-12 9:53
professionalWes Aday5-Sep-12 9:53 
GeneralRe: problem executing console application Pin
Pete O'Hanlon5-Sep-12 10:31
mvePete O'Hanlon5-Sep-12 10:31 
QuestionMS SQL to Remote path Pin
Warren Machanik5-Sep-12 6:57
Warren Machanik5-Sep-12 6:57 
I have an ISP that to say the least is not very helpful. I want to move to another ISP but need a backup of my database. Their Plesk database backup option is not work, and despite ticket after ticket I cannot get them to let me get a backup.

So I decided to do my own backup. The problem is I need the backup to backup to the local system, as their MS SQL box is not on the same machine as my web site. I have no idea how their local folder structure works but when I pull the current folder (see below) then folder is in the inetsrv folder.

I have a textbox (tbxFileName) that i populate to try and save the database but keep getting an error.

Can any one help. Code below:

C#
protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack) {
          string s = System.IO.Directory.GetCurrentDirectory();

          tbxFileName.Text = s + "\\dbbackup";
        }
    }


    protected void btnDoBackup_Click(object sender, EventArgs e)
    {
        try
        {
            string destDir = tbxFileName.Text;
            string StrConString = System.Configuration.ConfigurationManager.ConnectionStrings["MyDBConnString"].ToString();

            SqlConnection sqlcon = new SqlConnection(StrConString);
            SqlCommand sqlcmd = new SqlCommand();
            SqlDataAdapter da = new SqlDataAdapter();
            DataTable dt = new DataTable();

            //Check that directory already there otherwise create 
            if (!System.IO.Directory.Exists(destDir))
            {
                System.IO.Directory.CreateDirectory(destDir);
            }
            //Open connection
            sqlcon.Open();
            //query to take backup database
            sqlcmd = new SqlCommand("backup database test to disk='" + destDir + "\\DBBackup" + DateTime.Now.ToString("ddMMyyyy_HHmmss") + ".Bak'", sqlcon);
            sqlcmd.ExecuteNonQuery();
            //Close connection
            sqlcon.Close();
            ltrlMsg.Text = "Backup database successfully";
        }
        catch (Exception exp)
        {
            ltrlMsg.Text = "ERROR: " + exp.Message;
        }

    }


This the error I get if I try and run the above it fails at the exists folder point

Quote:
ERROR: Access to the path 'c:\windows\system32\inetsrv\dbbackup' is denied.

AnswerRe: MS SQL to Remote path Pin
Dave Kreskowiak5-Sep-12 7:36
mveDave Kreskowiak5-Sep-12 7:36 
GeneralRe: MS SQL to Remote path Pin
Warren Machanik5-Sep-12 9:11
Warren Machanik5-Sep-12 9:11 
GeneralRe: MS SQL to Remote path Pin
Dave Kreskowiak5-Sep-12 12:38
mveDave Kreskowiak5-Sep-12 12:38 
GeneralRe: MS SQL to Remote path Pin
Warren Machanik5-Sep-12 18:35
Warren Machanik5-Sep-12 18:35 
GeneralRe: MS SQL to Remote path Pin
Dave Kreskowiak5-Sep-12 19:17
mveDave Kreskowiak5-Sep-12 19:17 
AnswerRe: MS SQL to Remote path Pin
Bernhard Hiller5-Sep-12 21:29
Bernhard Hiller5-Sep-12 21:29 
AnswerRe: MS SQL to Remote path Pin
Warren Machanik6-Sep-12 0:41
Warren Machanik6-Sep-12 0:41 
Questiondebug console application Pin
dcof5-Sep-12 6:47
dcof5-Sep-12 6:47 
AnswerRe: debug console application Pin
Pete O'Hanlon5-Sep-12 6:58
mvePete O'Hanlon5-Sep-12 6:58 
GeneralRe: debug console application Pin
dcof5-Sep-12 7:58
dcof5-Sep-12 7:58 
GeneralRe: debug console application Pin
Pete O'Hanlon5-Sep-12 8:09
mvePete O'Hanlon5-Sep-12 8:09 
AnswerRe: debug console application Pin
Dave Kreskowiak5-Sep-12 7:32
mveDave Kreskowiak5-Sep-12 7:32 
GeneralRe: debug console application Pin
dcof5-Sep-12 8:02
dcof5-Sep-12 8:02 
GeneralRe: debug console application Pin
Dave Kreskowiak5-Sep-12 12:35
mveDave Kreskowiak5-Sep-12 12:35 
QuestionC# execute console application Pin
dcof5-Sep-12 5:39
dcof5-Sep-12 5:39 
AnswerRe: C# execute console application Pin
Eddy Vluggen5-Sep-12 5:54
professionalEddy Vluggen5-Sep-12 5:54 
AnswerRe: C# execute console application Pin
glennPattonWork35-Sep-12 5:59
professionalglennPattonWork35-Sep-12 5:59 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.