locked
Creating a Lightwitch Database Using a Script RRS feed

  • Question

  • I am new to Visual Studio 2012/Lightswitch and am having trouble creating a SQL Express database at the command prompt using a script file. The process errors out. What am I doing wrong?

    Microsoft Windows [Version 6.1.7601]
    Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

    C:\Users\cdm>sqlcmd -S .\SQLEXPRESS -i "C:\Temp\CreateAquarium.sql"
    Sqlcmd: Error: Microsoft SQL Server Native Client 11.0 : SQL Server Network Inte
    rfaces: Error Locating Server/Instance Specified [xFFFFFFFF]. .
    Sqlcmd: Error: Microsoft SQL Server Native Client 11.0 : Login timeout expired.
    Sqlcmd: Error: Microsoft SQL Server Native Client 11.0 : A network-related or in
    stance-specific error has occurred while establishing a connection to SQL Server
    . Server is not found or not accessible. Check if instance name is correct and i
    f SQL Server is configured to allow remote connections. For more information see
     SQL Server Books Online..

    C:\Users\cdm>

    Thursday, February 7, 2013 12:19 AM

Answers

  • VS 2012 installs a new piece of functionality in SQL Express called LocalDb. Rather than a full-blown installed instance, it's designed for devlopers who have no knowledge of installing & configuring a SQL instance.

    To access it in SSMS, you use (LocalDb)\v11.0 as the server name. In a command string it'd be Data Source =(LocalDb)\v11.0; plus the rest of your connection string.

    This blog post will give you a more detailed explanation:

    Introducing LocalDB, an improved SQL Express

    You'll need SSMS 2012 though, SMS 2008 won't know how to connect to LocalDb. You can install another instance of SQL Express, but there's no need to, once you know the "trick" of how to access LocalDb.


    Yann - LightSwitch Central - Click here for FREE Themes, Controls, Types and Commands
     
    Please click "Mark as Answer" if a reply answers your question. Please click "Vote as Helpful" , if you find a reply helpful.
     
    By doing this you'll help others to find answers faster.

    • Marked as answer by Mei152 Friday, February 8, 2013 5:29 PM
    Friday, February 8, 2013 5:17 AM
    Moderator

All replies

  • It looks like the user that is running the command does not have permissions to connect to the database. Have you verified that the server is running, and you can run commands.

    One option is to download the management tools for the express editions and use those.

    Thursday, February 7, 2013 1:30 AM
  • Yes, I was going to suggest trying it from the management console as well, instead of from the command line.

    Yann - LightSwitch Central - Click here for FREE Themes, Controls, Types and Commands
     
    Please click "Mark as Answer" if a reply answers your question. Please click "Vote as Helpful" , if you find a reply helpful.
     
    By doing this you'll help others to find answers faster.

    Thursday, February 7, 2013 8:39 AM
    Moderator
  • Thanks for the reply!

    What version of SQL Server Express installs with Visual Studio 2012?  I installed Express Management Studio 2012, and it can't seem to find a server to hook up to. While exploring my programs start menu, I came across a listing for SQL Server 2008 Installation Center.  That entry was not there before installing VS, so I suspect it is a byproduct of VS.

    Before I complicate things further by installing Express Management Studio 2008, I figured I should check in with you guys. Or, what would happen if I installed SQL Server Express 2012? Will multiple instances cause issues?

    Friday, February 8, 2013 2:56 AM
  • VS 2012 installs a new piece of functionality in SQL Express called LocalDb. Rather than a full-blown installed instance, it's designed for devlopers who have no knowledge of installing & configuring a SQL instance.

    To access it in SSMS, you use (LocalDb)\v11.0 as the server name. In a command string it'd be Data Source =(LocalDb)\v11.0; plus the rest of your connection string.

    This blog post will give you a more detailed explanation:

    Introducing LocalDB, an improved SQL Express

    You'll need SSMS 2012 though, SMS 2008 won't know how to connect to LocalDb. You can install another instance of SQL Express, but there's no need to, once you know the "trick" of how to access LocalDb.


    Yann - LightSwitch Central - Click here for FREE Themes, Controls, Types and Commands
     
    Please click "Mark as Answer" if a reply answers your question. Please click "Vote as Helpful" , if you find a reply helpful.
     
    By doing this you'll help others to find answers faster.

    • Marked as answer by Mei152 Friday, February 8, 2013 5:29 PM
    Friday, February 8, 2013 5:17 AM
    Moderator
  • Thank you, Yann!

    That solved my immediate issue. The script ran fine.

    I have some other questions regarding Lightswitch development and SQL Server, but will post them on a new thread. 

    Again, many thanks.

    Friday, February 8, 2013 5:34 PM
  • You're very welcome! :-)

    Yann - LightSwitch Central - Click here for FREE Themes, Controls, Types and Commands
     
    Please click "Mark as Answer" if a reply answers your question. Please click "Vote as Helpful" , if you find a reply helpful.
     
    By doing this you'll help others to find answers faster.

    Sunday, February 10, 2013 2:07 PM
    Moderator
  • HI

    I have this same error, how did you fixed it? I'm using Visual Studio 2013 Preview

    Cheers

    Monday, August 12, 2013 5:10 PM