connection-string

How can I get the connection string for an SQL Express database listed in LINQPad?

跟風遠走 提交于 2019-12-04 04:21:11
Is there an easy way to get the connection string of a database listed in the connection window of LINQPad (other than using the object explorer of Visual Studio)? Jay Walker Making sgmoore 's comment into an answer: try this.Connection.ConnectionString.Dump(); In LinqPad 5 if your Language dropdown is set to C# Program and you have a database selected in the Connection dropdown, then you can get your string using string c = LINQPad.Util.CurrentDataContext.Connection.ConnectionString; 来源: https://stackoverflow.com/questions/25360921/how-can-i-get-the-connection-string-for-an-sql-express

Can't connect to local SQL Server DB with connection string, but VS can

橙三吉。 提交于 2019-12-04 03:50:10
问题 I'm trying to connect to a local Sql Server 2012 database instance trough Visual Studio 15 using connection string. While I've been able to connect to the DB through the Visual Studio SQL Server Object Explorer and run a test procedure successfully, I'm unable to do so in my project using connection string. Here's my connection string that was given by the SQL Server Object Explorer <connectionStrings> <add name="objConnLocal" connectionString="Data Source=DESKTOPIVO;Integrated Security=True

C# connection string in web.config file

心已入冬 提交于 2019-12-04 03:40:33
In my code behind page, how do I access the connection string which is stored in my web.config file? Kyle Sonaty System.Web.Configuration.WebConfigurationManager.ConnectionStrings["YouConnStringName"].ConnectionString; This requires references to System.Configuration.dll and System.Web.dll. How to: Read Connection Strings from the Web.config File From comment on http://msdn.microsoft.com/en-us/library/ms178411.aspx string c = System.Web.Configuration.WebConfigurationManager.ConnectionStrings["myconnectionstringname"].ConnectionString; Requires your project to reference to System.Web and System

Difference between these connection strings?

耗尽温柔 提交于 2019-12-04 03:31:09
Can anybody tell me the effective difference between the following connection strings: <add key="ConnectionString" value="server=tcp:192.168.0.12\Sqlserver2005;database=;user id=sa;password=;"> <add key="ConnectionString" value="server=192.168.0.12\Sqlserver2005;database=;user id=sa;password=;Network Library=DBMSSOCN;"> I believe both are effectively the same. Specifying "Network Library=DBMSSOCN" explicitly connects using TCPIP and prefixing server value with TCP does the same thing. Please tell me if there is any difference or any performance implication of specifying these settings in web

Connecting to SQL CE db using SQLConnection

China☆狼群 提交于 2019-12-04 03:16:24
Pretty straightforward question. I'm building an app which reads data from a SQL Server 2005 instance. I wanted to run some tests on my laptop (which does not have SQL 2005) so I was looking at swapping in a local database for the purpose of the tests. I'm using VS2008 so the Compact Edition DB seemed a natural choice. I had hoped to just swap out my connection string, but it seems It will only let me connect to the CE database using the SqlCeConnection and not SqlConnection. Any way around this, modifiers I can use in the connection string perhaps? It's actually very possible to user SQL CE

SQL Server Error “Named Pipes Provider: Could not open a connection to SQL Server [53]”

与世无争的帅哥 提交于 2019-12-04 03:09:50
问题 I used to have a desktop application pointing to a Sybase database through an .ini file that had this connection string: CONNECTION_NAME = "DSN="Dna_Name";UID="User";PWD="Password"" It worked perfectly. A few days ago the database has been migrated to SQL Server 2008 R2 and I need to update the .ini file to redirect the new production server. I updated the connection string as follow: CONNECTION_NAME = "Provider=SQLNCLI10.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=

Silverlight Entity Framework Dynamic Connection String

扶醉桌前 提交于 2019-12-04 02:21:58
问题 I have the same data model on a bunch of different servers. I want to dynamically create a connection string based on who my user is and what they are doing. My users can have multiple databases on multiple servers. I need a clean way to build a connectoin string when I create my DomainService. I see that the DomainService has an override (inherited from LinqToEntitiesDomainService) called CreateObjectContext() that would allow me to set any connection string I want, then return the new

How can I switch between 2 Connection Strings in my Web.Config (Activate one for DBML)

一世执手 提交于 2019-12-03 23:20:22
I have two connection strings (both in Web.Config: CS_Local and CS_Production) for my DBML (Linq to SQL). In my Global.Asax/Application_Start I run some production preparation methods if the request is non-local (!HttpContext.Current.Request.IsLocal). Within that part, I'd also like to change the current connection string used by my DBML from the standard CS_Local to CS_Production. How would I do that? Some help please.. You can define the dbml context on the fly with: string connectionString = HttpContext.Current.Request.IsLocal ? ConfigurationManager.ConnectionStrings["CS_Local"]

Is there a difference between (local), '.' and localhost?

孤街浪徒 提交于 2019-12-03 23:19:23
问题 I've used all three of these when making local programmatic connections to databases. Is there any real difference between them? 回答1: The final result is the same. The difference is: 'localhost' resolves at the TCP/IP level and is equivalent to the IP address 127.0.0.1 Depending on the application "(local)" could be just an alias for 'localhost'. In SQLServer, '(local)' and '.' mean that the connection will be made using the named pipes (shared memory) protocol within the same machine (doesn

EF7 change connectionstring at runtime

此生再无相见时 提交于 2019-12-03 23:09:52
问题 In the previous versions of EF we were able to alter the dbcontext connection string as below : context.Database.Connection.ConnectionString = "the new connectionstring"; How can we do this with EF7? Thank you 回答1: I found the solution : https://github.com/aspnet/EntityFramework/wiki/Configuring-a-DbContext#config-from-external-code Context Code public class BloggingContext : DbContext { public BloggingContext(DbContextOptions options) : base(options) { } public DbSet<Blog> Blogs { get; set;