Wednesday, March 28, 2012

Iam trying to backup my database but nothing is backedup and no error message is displayed

Iam trying to backup my database but nothing is backedup and no error message is displayed. Here is my code.

<%

@.PageLanguage="VB" %>

<%

@.ImportNamespace="System.Data.SqlClient" %>

<%

@.ImportNamespace="System.Data" %>

<%

@.ImportNamespace="System.Net.Mail" %>

<!

DOCTYPEhtmlPUBLIC"-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<

scriptrunat="server">

Protected Sub LinkButton1_Click(ByVal sender As Object, ByVal e As System.EventArgs)

Try

Dim con As SqlConnection

con = New SqlConnection("Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\safetydata.mdf;Integrated Security=True;User Instance=True")

Dim com As New SqlCommand("BACKUP DATABASE safetydata TO c:\backuptest")

com.Connection = con

com.Connection.Open()

com.ExecuteNonQuery()

com.Connection.Close()

Response.Redirect("\Developer\Backup_success.aspx")

Catch exAs Exception

Response.Redirect(

"~\Developer\backup_error.aspx")EndTryEndSub

</

script>

<

htmlxmlns="http://www.w3.org/1999/xhtml">

<

headrunat="server"><title>BackUP Page</title>

Try:

EXEC sp_addumpdevice 'disk', 'safetydataBAKUP',
'c:\backuptest\safetydata.bak'

-- Back up the full safetydata database.
BACKUP DATABASE safetydata
TO safetydataBAKUP

Check also if user under which SQL server (not web page, not you) is running has rights to access c:\backuptest directory?

|||

Ok iam gonna try that but it would also be helpful to me if you gave just a one line explanation of what the lines below do.

EXEC sp_addumpdevice 'disk', 'safetydataBAKUP',
'c:\backuptest\safetydata.bak'


Thanksjpazgier

|||

See help topic examples for BACKUP DATABASE in Enterprise manager T-SQL Help

No comments:

Post a Comment