connection-string

Read connection string from web.config

本小妞迷上赌 提交于 2019-11-26 03:49:32
问题 How can I read a connection string from a web.config file into a public class contained within a class library? I\'ve tried: WebConfigurationManager ConfigurationManager But these classes are not recognized within my class library. 回答1: Add System.Configuration as a reference. For some bizarre reason it's not included by default. 回答2: You need to add a reference to System.Configuration and then use: System.Configuration.ConfigurationManager. ConnectionStrings["connectionStringName"]

What is the MySQL JDBC driver connection string?

安稳与你 提交于 2019-11-26 03:38:42
问题 I am new to JDBC and I am trying to make a connection to a MySQL database. I am using Connector/J driver, but I cant find the JDBC connection string for my Class.forName() method. 回答1: Assuming your driver is in path, String url = "jdbc:mysql://localhost/test"; Class.forName ("com.mysql.jdbc.Driver").newInstance (); Connection conn = DriverManager.getConnection (url, "username", "password"); 回答2: Have you read the documentation? https://dev.mysql.com/doc/connector-j/en/connector-j-reference

Entity Framework change connection at runtime

你离开我真会死。 提交于 2019-11-26 03:19:49
问题 I have a web API project which references my model and DAL assemblies. The user is presented with a login screen, where he can select different databases. I build the connection string as follows: public void Connect(Database database) { //Build an SQL connection string SqlConnectionStringBuilder sqlString = new SqlConnectionStringBuilder() { DataSource = database.Server, InitialCatalog = database.Catalog, UserID = database.Username, Password = database.Password, }; //Build an entity

How do I set a connection string config programmatically in .net?

可紊 提交于 2019-11-26 03:09:37
问题 I\'d like to set a connection string programmatically, with absolutely no change to any config files / registry keys. I have this piece of code, but unfortunately it throws an exception with \"the configuration is read only\". ConfigurationManager.ConnectionStrings.Clear(); string connectionString = \"Server=myserver;Port=8080;Database=my_db;...\"; ConnectionStringSettings connectionStringSettings = new ConnectionStringSettings(\"MyConnectionStringKey\", connectionString);

Setting up connection string in ASP.NET to SQL SERVER

寵の児 提交于 2019-11-26 02:07:07
问题 I\'m trying to set up a connecting string in my web.config file (Visual Studio 2008/ASP.NET 3.5) to a local server (SQL server 2008). In my web.config, how and where do I place the connection string? Here\'s what web.config file looks like right now: http://imwired.net/aspnet/Online_web.config 回答1: You can also use this, it's simpler. The only thing you need to set is "YourDataBaseName". <connectionStrings> <add name="ConnStringDb1" connectionString="Data Source=localhost;Initial Catalog

Get connection string from App.config

南笙酒味 提交于 2019-11-26 01:35:24
问题 var connection = ConnectionFactory.GetConnection( ConfigurationManager.ConnectionStrings[\"Test\"] .ConnectionString, DataBaseProvider); And this is my App.config: <?xml version=\"1.0\" encoding=\"utf-8\" ?> <configuration> <connectionStrings> <add name=\"Test\" connectionString=\"Data Source=.;Initial Catalog=OmidPayamak;Integrated Security=True\" providerName=\"System.Data.SqlClient\" /> </connectionStrings> </configuration> But when my project runs this is my error: Object reference not

How to set SQL Server connection string?

断了今生、忘了曾经 提交于 2019-11-26 01:07:11
问题 I\'m developing a simple C# application, I\'d like to know this: When I connect my application to SQL Server on my PC, I know the connection string (server name, password etc.), but when I connect it to another PC, the SQL Server connection string is different. Is there a common account in SQL Server that come with default account that can connect? I have heard about sa account in SQL Server, what is sa ? 回答1: // .NET DataProvider -- Standard Connection with username and password using System

Java JDBC - How to connect to Oracle using Service Name instead of SID

坚强是说给别人听的谎言 提交于 2019-11-25 23:36:27
问题 I have a Java application that uses JDBC (via JPA) that was connecting to a development database using hostname, port and Oracle SID, like this: jdbc:oracle:thin:@oracle.hostserver1.mydomain.ca:1521:XYZ XYZ was the Oracle SID. Now I need to connect to a different Oracle database that does not use a SID, but uses an Oracle \"Service Name\" instead. I tried this but it doesn\'t work: jdbc:oracle:thin:@oracle.hostserver2.mydomain.ca:1522:ABCD ABCD is the Service Name of the other database. What

What is the difference between Integrated Security = True and Integrated Security = SSPI?

一世执手 提交于 2019-11-25 23:24:25
问题 I have two apps that use Integrated Security. One assigns Integrated Security = true in the connection string, and the other sets Integrated Security = SSPI . What is the difference between SSPI and true in the context of Integrated Security? 回答1: According to Microsoft they are the same thing. When false , User ID and Password are specified in the connection. When true, the current Windows account credentials are used for authentication. Recognized values are true , false , yes , no , and