Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7062851
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T04:38:37+00:00 2026-05-28T04:38:37+00:00

I am using the following code to backup my database… Dim con As SqlConnection

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T04:38:38+00:00Added an answer on May 28, 2026 at 4:38 am

    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.

    try
      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()
    catch e as SqlException
        Console.WriteLine("State: " & e.State)
    end try
    

    Possible States:

    ERROR STATE ERROR DESCRIPTION
    2 and 5     Invalid userid
    6           Attempt to use a Windows login name with SQL Authentication
    7           Login is disabled, and the password is incorrect
    8           Password mismatch
    9           Invalid password
    11 and 12   Valid login but server access failure
    13          SQL Server service paused
    18          Change password required
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using the following code: Private Sub MakeMeSomeXmlBeforeRyanGetsAngry() Dim db As New MyDBDataContext Dim customer
I am using the following code snippet to copy/backup database Public Sub backupData() Try
i am using the following code snippet to backup/restore database Backup works fine but
I'm using the following code to restore a backup sql database with C# and
I can drop a SqlServer Backup Device using SQL-DMO using the following pseudo-code: SQLDMO.SQLServer2
I'm using following code but cannot return data from MySQL. This is the output:
I want to backup my database using mysql dump. This is the code I
I am trying to backup the database using mysql and c# by using following
I am trying to restore the database file(backup.sql) using c# by the following method...
I'm using the following code to back up a SQL Database : void BackupDatabase(string

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.