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

  • SEARCH
  • Home
  • 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 7488741
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T15:01:24+00:00 2026-05-29T15:01:24+00:00

I am using following code to detach my DB from SQL Server express. Please

  • 0

I am using following code to detach my DB from SQL Server express. Please advise if there is something wrong with it. I am getting an error on it.

"Could not locate entry in sysdatabases for database 'EXEC master'. No entry found with that name. Make sure that the name is entered correctly."

The code I am using is

 Dim conn2 As New SqlConnection("Server=MyHomeServer\SQLExpress;Database=master;Trusted_Connection=False;User ID=sa;Password=abc123;")
    Dim cmd2 As New SqlCommand("", conn2)
    cmd2.CommandType = CommandType.StoredProcedure
    cmd2.CommandText = "EXEC master.dbo.sp_detach_db @dbname = N'MyHomeDBTestPWD'"
    conn2.Open()
    cmd2.Connection = conn2
    cmd2.ExecuteNonQuery()
  • 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-29T15:01:25+00:00Added an answer on May 29, 2026 at 3:01 pm

    You are assiging this the wrong way. You are allocating a proper SQL statement in the CommandText when you only need to add the Stored Procedure name. You will then need to add a Parameter to your SqlCommand.

    Dim cmd2 As New SqlCommand("", conn2) 
    cmd2.CommandType = CommandType.StoredProcedure
    cmd2.CommandText = "sp_detach_db"
    cmd2.Parameters.AddWithValue("@dbname", "MyHomeDBTestPWD")
    cmd2.ExecuteNonQuery()
    

    If you are alternatively wanting to execute your SQL statement, then you just need to change your CommandType to CommandType.Text

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using following code to attach my database to SQL Server. The problem
I'm using following code but cannot return data from MySQL. This is the output:
Using the following code I get a nice formatted string: Request.QueryString.ToString Gives me something
Using the following code, I'm retrieving a list of Integers from a DB and
Im using the following code to output all the nodes from the xml shown.
i am using following code for navigating from one view to another view in
I am using following code I found from in the web to authenticate users
I am using following code to connect to MySql Db but it gives error.
I am using following code to get List from xml file - public static
I am Using Following Code for Send the Email from my application but problem

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.