connection-string

App.Config Connection String

前提是你 提交于 2019-12-22 14:54:07
问题 In my windows form i have connection string in app.config as <configuration> <configSections> </configSections> <connectionStrings> <add name="Database" connectionString="Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\Database.accdb" providerName="System.Data.OleDb" /> </connectionStrings> <startup> <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" /> </startup> </configuration> And in all classes i am using the following code to connect to the database. string

Excel VBA; Updating a connection string

岁酱吖の 提交于 2019-12-22 11:13:15
问题 I'm just trying to get VBA to update an OLEDB connection string. When I step through the code, I don't get any errors but the connection refresh fails and when I examine the connection string in the UI, it's obvious that my code has not changed it at all (hence the refresh failure). What have I missed? Here is the code: Sub UpdateQueryConnectionString(ConnectionString As String) With ActiveWorkbook.Connections("Connection Name"). _ OLEDBConnection .Connection = StringToArray(ConnectionString)

OLEDBConnection.Open() generates 'Unspecified error'

旧城冷巷雨未停 提交于 2019-12-22 10:54:01
问题 I have an application that uploads an Excel .xls file to the file system, opens the file with an oledbconnection object using the .open() method on the object instance and then stores the data in a database. The upload and writing of the file to the file system works fine but I get an error when trying to open the file on our production server only . The application works fine on two other servers (development and testing servers). The following code generates an 'Unspecified Error' in the

C# SqlCommand Connection.Open() issue

天涯浪子 提交于 2019-12-22 10:46:10
问题 I have a C# ASP.NET web application an I am trying to populate an ASP:DropDownList with a column in a database table. My Code: using System; using System.Collections.Generic; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Data; using System.Data.SqlClient; using System.Configuration; using System.Web.Configuration; namespace CRM2Sage { public partial class SOPOrderEntry : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { Fill1();

Get Number of open connection string in my application

会有一股神秘感。 提交于 2019-12-22 09:43:03
问题 I'm programming an application with C# and SQL Server 2008. How can I get the number of opened connections that are not already closed? Also if I open a connection with 20 minute timeout, and do not close it - will it closed after 20 minutes? 回答1: This shows the no of connections per each DB: SELECT DB_NAME(dbid) as DBName, COUNT(dbid) as NumberOfConnections, loginame as LoginName FROM sys.sysprocesses WHERE dbid > 0 GROUP BY dbid, loginame And this gives the total: SELECT COUNT(dbid) as

Changing your web.config from your ASP.NET application

萝らか妹 提交于 2019-12-22 08:37:21
问题 I need to change the database connection string in the web.config file but havent got a clue how to go about this. Does anyone have any experience with that? UPDATE Sorry, not very clear above, I want to be able to change a connection string from the web application after it has been deployed 回答1: Configuration myConfiguration = WebConfigurationManager.OpenWebConfiguration("~"); //appSettings configuration myConfiguration.AppSettings.Settings["xxx"].Value = "yyy"; //database connections

net core 2.0 appsettings.json save on bin directory

烈酒焚心 提交于 2019-12-22 07:39:08
问题 I am new in net core 2.0 . I am connecting to datbase. I am used to use an App.Config or Web.Config to set the connection string. But in net core 2.0 uses appsettings.json file instead. When I compile de Application, appsettings.json file is not generated in bin directory. So when I run the appplication from Console c>dotnet prj.dll thrown an excepción because connection file is not found. My question is... I have to copy appsettings.json file manually to bin directory or is there a way to

EF4 and Connection String

烈酒焚心 提交于 2019-12-22 04:55:16
问题 I have a 3 tiered project. 1) Project.Data (EDMX file) 2) Project.Model (POCO's) 3) Project.Console (Console app) I have added the connection string into the Project.Console . <?xml version="1.0" encoding="utf-8"?> <configuration> <connectionStrings> <add name="ProjectEntities" connectionString="metadata=res://*/Project.csdl|res://*/Project.ssdl|res://*/Project.msl;provider=System.Data.SqlClient;provider connection string="Data Source=PC\SQLEXPRESS;Initial Catalog=Project;Integrated Security

Get user and password from ConnectionStringSettings

隐身守侯 提交于 2019-12-22 01:33:35
问题 How can I get the user and password from such a connectionString in the app.config with a .NET function? Of course I could read that string and get the value after the ID= and Password=. <connectionStrings> <add name="MyConString" connectionString="Data Source=(local);Initial Catalog=MyDatabase;Persist Security Info=True;User ID=MyUsername Password=MyPassword;Connect providerName="System.Data.SqlClient"/> </connectionStrings> 回答1: use the ConnectionBuilderClass SqlConnectionStringBuilder

SQLServerCE DefaultConnectionFactory

杀马特。学长 韩版系。学妹 提交于 2019-12-22 00:44:22
问题 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