I am using the following code to backup my database…
Dim con As SqlConnection
Dim cmd As SqlCommand
con = New SqlConnection("Data Source=.\SQLEXPRESS;Initial Catalog=LIC;Trusted_Connection = yes")
cmd = New SqlCommand("BACKUP DATABASE LIC to disk='C:\Backup\ICLS.bak'", con)
con.Open()
cmd.ExecuteNonQuery()
con.Close()
But I get this error
Cannot open database "LIC" requested by the login. The login failed.
Login failed for user 'mono-PC\mono'.
Any help is appreciated.
Try this. It will still fail, but it will print a number (the State of the Exception). A table is below that lists the possible states and the reasons why they might occur (from http://blogs.msdn.com/b/sql_protocols/archive/2006/02/21/536201.aspx and http://msdn.microsoft.com/en-us/library/ms366351.aspx). See those links for resolution.
Possible States: