locked
How do I get my local visual studio to work with local sql server as opposed to remote sql server RRS feed

  • Question

  • User745803033 posted

    I have visual studio web developer express.  I develop a website on my local PC that works with a SQL server database hosted on a server at a web-hosting company.  I would like to script out the database, (which I know how to do) and then put a local version of SQL server (perhaps 'localdb', perhaps another) and run the script so that I recreate the database on my local PC.  Then I want to link to it.  I've tried this a couple of times over the years, and I end up download 'localdb', which after running the install program, is unfindable on my PC.  So I can't run the script within it.  And even if I could, I would not know the connection string.

    Thanks.

    Wednesday, September 2, 2015 9:59 AM

Answers

All replies

  • User2024324573 posted

    If you are using Visual Studio 2012 or 2013 then you can connect to the localdb database in the following ways:

    • From the View  menu click Server Explorer and when it open click on Connect to Database (which is shown on the top) and then you will be given the option for selecting the client (data source) and server name. From the Data Source select  Microsoft SQL Server(SqlClient) and in the server name type (localdb)\v11.0  and from the bottom click Test Connection  button, if the connection tests successfully then you localdb is fine and you are able to use it.
    • You can also use SQL Server Management Studio to connect to the localdb database. From the management studio click connect->Database Engine and then provide the Server name as  (localdb)\v11.0 and Authentication as Windows Authentication and then click Connect button to connect.
    • If both of the attempts don't work, then you need to check whether the SQL Server service is running or not.

    Hope this will help.

    Wednesday, September 2, 2015 3:54 PM
  • User-166373564 posted

    Hi,

    There are some examples of SQL Server connection strings for typical ASP.NET web application scenarios. It also includes instructions for converting connection strings between SQL Server Express and LocalDB. such as:

    <add name="ConnectionStringName"
        providerName="System.Data.SqlClient"
        connectionString="Data Source=(LocalDB)\v11.0;AttachDbFileName=|DataDirectory|\DatabaseFileName.mdf;InitialCatalog=DatabaseName;Integrated Security=True;MultipleActiveResultSets=True" />
    

    More information: https://msdn.microsoft.com/en-us/library/jj653752(v=vs.110).aspx 

    Please let me know if you need any help.

    With regards,

    Angie

    Thursday, September 3, 2015 3:58 AM
  • User745803033 posted

    An odd thing happened when I tried to follow directions above.  I already had sql server management studio 2014 on my local PC, because I administer a remote server with it.  But I assumed I did not have anything else, so I downloaded sql server 2014 express, and ran it.  It passed all the checks except being able to restart the PC, so I restarted the PC myself, and then ran 'setup'.  It succeeded with 'setup', but I can't find the programs that I installed on my PC.

    I have a BAK file that I made from my remote database, and I also have a SQL file which is the scripted-out commands that can create that database.  But I can't use either if I can't find localdb, or any other database on my local PC.

    Does this happen to anyone else?

    Thanks.

    Wednesday, September 9, 2015 9:39 AM
  • User-166373564 posted

    Hi,

    But I can't use either if I can't find localdb, or any other database on my local PC.

    Do you have trouble to connect to local/ remote database in SQL Server management studio?

    Here are some resources for you: Connecting to the Database Engine and View or Configure Remote Server Connection Options

    hope it helps.

    With regards,

    Angie

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, September 16, 2015 3:55 AM