Quantcast
Channel: .NET Framework Class Libraries forum
Viewing all articles
Browse latest Browse all 8156

Can not back up sql localdb at run time

$
0
0

Hello everyone,

This is my first time using sql localdb. I do not know am I doing right or not. This is what I did.

1. I install SqlLocalDB.msi(downloaded from Microsoft).

2. Add a new project(Windows forms application) in visual studio 2008.

3. Add a new windows form called Test to test insert, update, delete and backup/restore database.

4. I click "add New Data Source" -> Choose "Database" -> Click "New connection" -> insert Database file name (Use Windoes Authentication)

5. It is working when I test with insert, update and delete. But got error message when I try to backup database.

Here are my coding for backup button......

      If DialogBackup.ShowDialog() = DialogResult.OK Then
            Dim dbCommand As New SqlCommand
            dbCommand.Connection = dbConnection
            dbCommand.CommandText = "BACKUP DATABASE myTestDB TO DISK = @BackupFullPath"
            dbCommand.CommandType = CommandType.Text
            dbCommand.Parameters.Clear()
            dbCommand.Parameters.Add("@BackupFullPath", SqlDbType.VarChar)
            dbCommand.Parameters("@BackupFullPath").Value = DialogBackup.FileName
            Try
                dbConnection.Open()
                dbCommand.ExecuteNonQuery()
                dbConnection.Close()
                MsgBox("Database Back-up successed.")
            Catch ex As Exception
                MsgBox("Database Back-up Failed." & vbNewLine & ex.Message)
            Finally
                dbCommand.Dispose()
            End Try
        End If

The error message is here....

Could not locate entry in sysdatabases for database 'myTestDB'. 
No entry found with that name.
Make sure that the name is entered correctly.
BACKUP DATABASE is terminating abnormally.

Please help.

Thanks a lot.


Viewing all articles
Browse latest Browse all 8156

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>