backing up/moving mssql databases
-
Is there anyway (using msde) to backup a database from a mssql 2000 server? or any program, code etc. I would like to back up my database off my website localy onto my own computer (Just in case anything happens or I move providers). Thanks for any help you can provide.
-
Is there anyway (using msde) to backup a database from a mssql 2000 server? or any program, code etc. I would like to back up my database off my website localy onto my own computer (Just in case anything happens or I move providers). Thanks for any help you can provide.
-
I keep getting an error about an "Unrecognized escape sequence" this is the line SqlCommand cmd1 = new SqlCommand("EXEC sp_addumpdevice 'disk','databasedump','C:\temp\database.dat") What am I doing wrong?
If you're using C#, you need to either prefix the string with
@
, or you need to double the backslash characters - the\
character begins a special character combination in all C-based languages. See the documentation for string[^] or the specification for string literals[^] (although this is probably too much detail!) Specifically, the '\t' will be interpreted as a TAB character and '\d' is causing the error you mention (since this is not a valid escape). You also appear to be missing a single-quote mark to close the last string parameter. -
If you're using C#, you need to either prefix the string with
@
, or you need to double the backslash characters - the\
character begins a special character combination in all C-based languages. See the documentation for string[^] or the specification for string literals[^] (although this is probably too much detail!) Specifically, the '\t' will be interpreted as a TAB character and '\d' is causing the error you mention (since this is not a valid escape). You also appear to be missing a single-quote mark to close the last string parameter.ok I thought that's what it was but I got sidetracked on another project and never had time for it untill today (what good timing huh ;)) I am trying to do the backup command you showed me and I am delaring them like this
SqlCommand cmd1 = new SqlCommand("EXEC sp_addumpdevice 'disk','localBackup','C:\\temp\\database.dat'",sqlConnection1); SqlCommand cmd2 = new SqlCommand("BACKUP DATABASE databaseName TO localBackup",sqlConnection1);
I am calling them from within this try blocktry { cmd1.ExecuteNonQuery(); cmd2.ExecuteNonQuery(); //sqlBackup.Commit(); tbError.Text = "Finished"; }
and running them as non queries (I tried them as transactions but it gave me this error "The procedure 'sp_addumpdevice' cannot be executed within a transaction") so I took them out and make them queries and now I get a problem with the Execute command saying I need a transaction property. "Execute requires the command to have a transaction object when the connection assigned to the command is in a pending local transaction. The Transaction property of the command has not been initialized." Now I am really confused :( -
ok I thought that's what it was but I got sidetracked on another project and never had time for it untill today (what good timing huh ;)) I am trying to do the backup command you showed me and I am delaring them like this
SqlCommand cmd1 = new SqlCommand("EXEC sp_addumpdevice 'disk','localBackup','C:\\temp\\database.dat'",sqlConnection1); SqlCommand cmd2 = new SqlCommand("BACKUP DATABASE databaseName TO localBackup",sqlConnection1);
I am calling them from within this try blocktry { cmd1.ExecuteNonQuery(); cmd2.ExecuteNonQuery(); //sqlBackup.Commit(); tbError.Text = "Finished"; }
and running them as non queries (I tried them as transactions but it gave me this error "The procedure 'sp_addumpdevice' cannot be executed within a transaction") so I took them out and make them queries and now I get a problem with the Execute command saying I need a transaction property. "Execute requires the command to have a transaction object when the connection assigned to the command is in a pending local transaction. The Transaction property of the command has not been initialized." Now I am really confused :(I suspect you've still got a
BeginTransaction
call outstanding on thesqlConnection1
object.