connection-string

Sql connection waits 15 seconds despite 3 seconds timeout in connection string

[亡魂溺海] 提交于 2019-12-04 22:25:08
问题 I have a website using Microsoft SQL 2008 server over local network. Sometimes, SQL server machine is rebooted, and so the website fails to connect to the database. If the machine is up and running, it will respond fast. If it's down, there is no need to wait for 15 seconds. 3 seconds are ok. I want to display apologizes on the website when the database is not reachable, and want to do it fast. But setting Connection Timeout=3 in connection string seems having no effect. The page spends 22

How to encrypt app.config?

岁酱吖の 提交于 2019-12-04 21:42:40
问题 Create app.config in wpf (c#) <?xml version="1.0"?> <configuration> <connectionStrings> <clear /> <add name="Name" providerName="MySql.Data" connectionString="Server=.net;Uid=;Pwd=H;Database=;charset=utf8;Allow Zero Datetime=true;" /> </connectionStrings> </configuration> used code C#: Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); ConnectionStringsSection conStr = config.ConnectionStrings; if (!conStr.SectionInformation.IsProtected) { conStr

NHibernate config connection string info

China☆狼群 提交于 2019-12-04 21:04:53
What's the best way to store connection string info? I'd rather not just store the db password in NHib.config file. Michael Maddox Use encryption on the password and/or connection string and store the encrypted password/connection string in a config file of some sort. Then use my answer here to add the connection string value to the NHibernate Configuration object after decrypting it: How to load application settings to NHibernate.Cfg.Configuration object? Like: nHibernateConfiguration.SetProperty( NHibernate.Cfg.Environment.ConnectionString, Util.Decrypt(encryptedConnectionString)); Aim Kai

How to change App.config file at run time from textbox value?

纵饮孤独 提交于 2019-12-04 20:27:37
I have created a project which has App.config file. This App.config file is fixed. I wanna change connectionString at run time using textbox's value. Here are two textboxes textbox1 & textbox2 . I want to input in textbox & when I click the button then does it happen? How could I do that Exactly? Here is the sample code of App.config file: <?xml version="1.0" encoding="utf-8" ?> <configuration> <connectionStrings> <add name="DBconnection" connectionString="data source=ARIF\SQLEXPRESS;database=Library_Management_System; Integrated Security=SSPI;"/> </connectionStrings> </configuration> If I

Query data from SQL to MS Access: Local Tables vs Pass-Through Tables

时光毁灭记忆、已成空白 提交于 2019-12-04 19:40:46
I've created an application that uses the following logic to query data from SQL to my MS Access App. Using an ODBC connection I execute a stored procedure Using This is assigned as a Pass-Through Query to pull the data locally. It looks something like this: strSQL = "EXEC StoredProcedure " & Variable & " Call ChangeQueryDef("qryPassThrough", strSQL) Call SQLPassThrough(strQDFName:="qryPassThrough", _ strSQL:=strSQL, strConnect:=gODBCConn) Me.frmDataSheet.Form.RecordSource = "qryPassThrough" But, recently we have upgraded our SQL Server to 2016 using a high availability failover system - hence

Attaching database to my project [closed]

試著忘記壹切 提交于 2019-12-04 19:30:44
In my C# program I have a big problem: I add an SQL server database named "Behgozin_DB" to my project. I do the following steps for adding the database: In my SQL server management studio I detach my database In my visual studio from Data menu I add new data source My Connection String is: Data Source=(local);AttachDbFilename=|DataDirectory|\DB_Behgozin.mdf;Integrated Security=True Everything is OK but when I insert something into my database after closing the application , I can not see any data. But when I right click on my tables in my visual studio server explorer menu and choose show

Excel VBA - connect to sql with a trusted connection (no uid/pwd)

时间秒杀一切 提交于 2019-12-04 19:29:56
问题 Is there a way to have Excel connect to Sql Server using the current user's network windows authentication (trusted connection/integrated security)? I don't want to rely on a sql login or have a uid/password in my code. 回答1: I have this connectionstring in an Excel 2003 VBA project... "Provider=SQLOLEDB;Data Source=[You DB Name];Trusted_connection=yes;" And it works for me! (I'm using ADODB) 回答2: Driver={SQL Native Client};server=servernamehere;database=dbnamehere;Trusted_Connection=yes; http

SQLServerCE DefaultConnectionFactory

余生颓废 提交于 2019-12-04 19:28:17
I am using Entity Framework 4.1 and try to connect to a new SQLServerCE 4.0 database inside an MVC Web application. I am using this code Database.DefaultConnectionFactory = new SqlCeConnectionFactory("System.Data.SqlServerCe.4.0", "|DataDirectory|", "test.sdf"); And it raises this exception : Format of the initialization string does not conform to specification starting at index 86. What's wrong with this code? If I use Database.DefaultConnectionFactory = new SqlCeConnectionFactory("System.Data.SqlServerCe.4.0") It works and creates a database with a very long name matching my assembly name. A

ASP.NET: How to create a connection from a web.config ConnectionString?

倾然丶 夕夏残阳落幕 提交于 2019-12-04 18:44:16
问题 How do you construct a DbConnection based on a provider name ? Sample provider name s System.Data.SqlClient System.Data.OleDb System.Data.Odbc FirebirdSql.Data.FirebirdClient i have connection strings stored in my IIS server's web.config file: <connectionStrings> <add name="development" connectionString="Provider = IBMDA400; Data Source = MY_SYSTEM_NAME; User Id = myUsername; Password = myPassword;" providerName="System.Data.OleDb" /> <add name="live" connectionString="usd=sa;pwd=password

unable to retrieve metadata for unrecognized element providers

不打扰是莪最后的温柔 提交于 2019-12-04 15:57:51
问题 I get a message error whenever I try to add a controller with Entity framework template but I keep getting a error message unable to retrieve metadata for 'path' unrecognized element providers. (C:\Users\user\appdata\local\Temp-mp6124.tmp line 78) I know it's something related to connection string so here is my connection string <connectionStrings> <add name="NoktatyContext" connectionString="Data Source=(localdb)\v11.0; Initial Catalog=NoktatyContext-20140122154208; Integrated Security=True;