sql server express connection string

后端 未结 6 2390
北恋
北恋 2021-02-19 23:11

Is there a difference between sql server connection string and the express vesion?!

相关标签:
6条回答
  • 2021-02-19 23:51

    By default (though I don't recommend it1), Sql Express is installed as a named instance. That means you must connect like Server=servername.com\SQLEXPRESS as opposed to just Server=servername.com.

    As always, connectionstrings.com has the goodies.

    1 I don't recommend named instances because they run on a different port, which makes firewalling a PITA. Also, it makes little sense to me to run more than 1 MSSQL Server on a computer when you could just host multiple databases instead - so I'm not really sure what the point is.

    0 讨论(0)
  • 2021-02-19 23:53

    In addition to previous post: If you have troubles with setup Telerik samples on MSSQL Server 2008, you can do the following:

    1. Open LiveDemos Telerik VS solution
    2. Setup database connections for telerik .mdf files in VS master
    3. Copy connection string for connections to the web.config file
    4. And add "Integrated Security=True;User Instance=False" to the end of the strings.

    PS. Fred Morrison - thanx, you are my "man of day", I just fix Telerik Live Demo problem with you post help!

    0 讨论(0)
  • 2021-02-20 00:04

    The only difference is that you'll have to specify a named instance in the conn string, if Express was setup that way. 2005 had no option, but 2008 does.

    Data Source=localhost\SQLExpress
    

    Here's a great reference for connection strings.

    0 讨论(0)
  • 2021-02-20 00:05

    The connection string used to access SQL Server and SQL Server Express?

    Generally, no. That's the nice thing about using Express; develop with it locally and with minimal changes migrate your data access to SQL Server.

    0 讨论(0)
  • 2021-02-20 00:10

    I recently downloaded a sample application from the Telerik site and could not get it to run on my machine that has only SQL Server 2008 SP1 Developer Edition installed until I did a find and replace of all "User Instance=True" with "User Instance=False".

    Before anybody goes and gets their panties all twisted in a knot, hear me out first. My circumstances may be (but ought not be) unique in that instead of installing SQL Server 2008 Express just to run example applications (e.g., Telerik), I simply installed a second named instance of SQL Server named, you guessed it, sqlexpress on my copy of SQL Server 2008 Developer Edition. That way when the Telerik (or you name it) demo application tries to connect to "Data Source=.\sqlexpress", it's none the wiser that what it's really connecting too is "big SQL Server" (which is what SQL Server Developer Edition is for the purposes of this posting).

    The key conecpts (dare I say "money quote") you need to understand are these:

    SQL Express allows (actually assumes if missing) User Instance=True, so if you are running a named instance called sqlexpress on "big SQL" (Developer, Standard, Enterprise or Data Center), then you just need to find/replace User Instance=True with User Instance=False in the connecton string and your worries are over. Even the "Attach database" stuff (that I see in the Telerik connectionStrings section of their web.config) works on "big SQL" (contrary to what somebody posted earlier in this thread).

    Here's an actual example taken directly from the web.config of the Telerik web.config file after I "fixed it up":

    <connectionStrings>
        <add name="NorthwindConnectionString" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|Northwind.mdf;Integrated Security=True;User Instance=False" providerName="System.Data.SqlClient"/>
        <add name="TelerikConnectionString" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|Telerik.mdf;Integrated Security=True;User Instance=False" providerName="System.Data.SqlClient"/>
        <add name="NorthwindConnectionString35" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|Northwind.mdf;Integrated Security=True;User Instance=False" providerName="System.Data.SqlClient"/>
        <add name="TelerikConnectionString35" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|Telerik.mdf;Integrated Security=True;User Instance=False" providerName="System.Data.SqlClient"/>
        <add name="NorthwindEntities" connectionString="metadata=res://*;provider=System.Data.SqlClient;provider connection string=&quot;Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Northwind.mdf;Integrated Security=True;User Instance=False;MultipleActiveResultSets=True&quot;" providerName="System.Data.EntityClient"/>
        <add name="TelerikEntities" connectionString="metadata=res://*;provider=System.Data.SqlClient;provider connection string=&quot;Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Telerik.mdf;Integrated Security=True;User Instance=False;MultipleActiveResultSets=True&quot;" providerName="System.Data.EntityClient"/>
        <add name="EditorFileBrowserDatabase" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|EditorDBStorage.mdf;Integrated Security=True;User Instance=False" providerName="System.Data.SqlClient"/>
    </connectionStrings>
    
    0 讨论(0)
  • 2021-02-20 00:12

    Yes there is a difference- the big one being you won't have AttachDbFilename in the full SQL Server.

    SQL Server Express connection string:

    Server=.\SQLExpress;AttachDbFilename=c:\mydbfile.mdf;Database=dbname; Trusted_Connection=Yes;
    

    Typical normal SQL Server connection string:

    Data Source=myServerAddress;Initial Catalog=myDataBase;Integrated Security=SSPI;
    

    See connectionStrings.com for more info.

    0 讨论(0)
提交回复
热议问题