Login failed for user ‘NT AUTHORITY\NETWORK SERVICE’

I was experiencing a similar error message that I noticed in the Windows Event Viewer that read: Login failed for user ‘NT AUTHORITY\NETWORK SERVICE’. Reason: Failed to open the explicitly specified database. [CLIENT: local machine] The solution that resolved my problem was: Login to SqlExpress via SQL Server Management Studio Go to the “Security” directory … Read more

How to check if connection string is valid?

You could try to connect? For quick (offline) validation, perhaps use DbConnectionStringBuilder to parse it… DbConnectionStringBuilder csb = new DbConnectionStringBuilder(); csb.ConnectionString = “rubb ish”; // throws But to check whether the db exists, you’ll need to try to connect. Simplest if you know the provider, of course: using(SqlConnection conn = new SqlConnection(cs)) { conn.Open(); // … Read more

Escape quote in web.config connection string

Use " instead of ” to escape it. web.config is an XML file so you should use XML escaping. connectionString=”Server=dbsrv;User ID=myDbUser;Password=somepass"word” See this forum thread. Update: " should work, but as it doesn’t, have you tried some of the other string escape sequences for .NET? \” and “”? Update 2: Try single quotes for the … Read more

How to configure ProviderManifestToken for EF Code First

If you’re using EF 6 (just released) you have an alternative. Dependency Resolution You can use the new dependency resolution feature to register an implementation of IManifestTokenResolver (described in this preview documentation as IManifestTokenService). This article gives a bit more information on how to use DbConfiguration. The easiest way to use it is like this: … Read more

How to fix “The ConnectionString property has not been initialized”

Referencing the connection string should be done as such: MySQLHelper.ExecuteNonQuery( ConfigurationManager.ConnectionStrings[“MyDB”].ConnectionString, CommandType.Text, sqlQuery, sqlParams); ConfigurationManager.AppSettings[“ConnectionString”] would be looking in the AppSettings for something named ConnectionString, which it would not find. This is why your error message indicated the “ConnectionString” property has not been initialized, because it is looking for an initialized property of AppSettings named … Read more

A network-related or instance-specific error occurred while establishing a connection to SQL Server [closed]

Sql Server fire this error when your application don’t have enough rights to access the database. there are several reason about this error . To fix this error you should follow the following instruction. Try to connect sql server from your server using management studio . if you use windows authentication to connect sql server … Read more

Help with a OleDB connection string for excel files

Unfortunately, you can’t set ImportMixedTypes or TypeGuessRows from the connection string since those settings are defined in the registry. For the ACE OleDb driver, they’re stored at HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\14.0\Access Connectivity Engine\Engines\Excel in the registry. So, you can simplify your connection string to: conn.ConnectionString = @”Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\Nick\Desktop\Pricing2.xlsx;Extended Properties=””Excel 12.0 Xml;HDR=Yes;IMEX=1;”””; Once you set TypeGuessRows to 0 and … Read more