connection-string

Display a ConnectionString dialog

一世执手 提交于 2020-01-09 09:05:01
问题 I'm trying to create a program in C# that should be able to create, backup and restore a SQL Server database. For this, the user needs to be able to setup a connection string to the desired SQL Server (and database). I would like to use the same dialog as for example Visual Studio for creating the connection string. Is this possible? 回答1: Note: The dialog component referred to below is no longer available for download. Unless you have retrieved it in the past, you will probably not get this

error in mysql connection “The given key was not present in the dictionary”

不问归期 提交于 2020-01-06 19:53:26
问题 I have problem while connecting to mysql database using "ADO.NET Driver for MySQL (Connector/NET)" I got this exception The given key was not present in the dictionary. Edit: MySqlConnection con = new MySqlConnection("Server=localhost;Database=pgs_db;Uid=root;Pwd=;"); MySqlCommand com = new MySqlCommand(); com.CommandType = CommandType.StoredProcedure; com.Connection = con; com.CommandText = "getStudent"; con.Open(); MySqlDataReader dr =com.ExecuteReader(); GridView1.DataSource = dr;

Webconfig ConnectionString to connect SQL Server 2008 from Visual Studio 2012

纵然是瞬间 提交于 2020-01-06 14:59:10
问题 What is connection string for the following SQL server 2008 properties: DB Name : testDB 回答1: Try this connection string: Server=K-PC;Database=testDB;Trusted_Connection=True; You can find more details on connection strings in this link: http://www.connectionstrings.com/sql-server/ 来源: https://stackoverflow.com/questions/24851744/webconfig-connectionstring-to-connect-sql-server-2008-from-visual-studio-2012

Generate connection string dynamically in ASP.NET MVC

£可爱£侵袭症+ 提交于 2020-01-06 12:44:41
问题 Hi I am working on ASP.NET MVC project. Currently I am using Model first approach, where i used to add database manually by using ADO.NET model. Currently I have 4 database and I have 4 connection strings in web.config file. It was fine till now, since I was working on development environment. But now I need to move my code to live and problem is, in live we have like 40 to 50 databases. So what I should do is, generate connection string dynamically when user wants to connect to particular

Remote SQL Server connection string

心不动则不痛 提交于 2020-01-05 08:26:13
问题 I have had a project where SQL Server and development all worked locally. The following connection string was used: SqlConnection connection= new SqlConnection("Data Source=.\\MYDB;Initial Catalog=Database;Integrated Security=true"); connection.Open(); My development team is now growing and I am looking to have another developer access this same database. He will need to alter this connection string and we are trying to workout what to change in the string - so far we have tried:

Programmatically creating a connection string for mapping an Entity Framework Code-First model with an existing Sql Server Compact database

北城余情 提交于 2020-01-05 07:38:36
问题 I've successfully mapped an Entity Framework Code-First data model with an existing Sql Server Compact database by a declarative approach using app.config but it would be great if I could build such connection programmatically with perhaps the help of the EntityConnectionStringBuilder (System.Data.EntityClient) class. Unfortunately this approach is not working as the [DbContext].Connection.ConnectionString is not accepting most of its properties. Here's the actual working code with the faulty

Reading from the stream has failed - MySqlException

我与影子孤独终老i 提交于 2020-01-05 07:38:29
问题 I'm trying to open a connection to a MySql database using the following code piece: string connectionString = "Server=ip_number;Database=database_name;Uid=uid;Password=password"; MySqlConnection connection; connection = new MySqlConnection(connectionString); connection.Open(); And here is the exception I get: I'm using the latest mysql connector (downloaded from here). What am I missing? Thanks in advance, 回答1: May you try this: Connection to server: string connectionString= "datasource

Reading from the stream has failed - MySqlException

若如初见. 提交于 2020-01-05 07:38:02
问题 I'm trying to open a connection to a MySql database using the following code piece: string connectionString = "Server=ip_number;Database=database_name;Uid=uid;Password=password"; MySqlConnection connection; connection = new MySqlConnection(connectionString); connection.Open(); And here is the exception I get: I'm using the latest mysql connector (downloaded from here). What am I missing? Thanks in advance, 回答1: May you try this: Connection to server: string connectionString= "datasource

App Config - The Login is from an untrusted domain

狂风中的少年 提交于 2020-01-05 04:30:30
问题 First, I try to connect to sql server of other computer(PC1-PC\Instance1) through ssms with Windows Authentication but got this error Login failed. The login is from an untrusted domain and cannot be used with Windows authentication. I resolve the error when I edit the password of sa to 1234 in PC1-PC\Instance1. Then connect in the ssms with SQL Server Authentication. And successfully connected. The problem is in my Winforms app config, I set the connection to this: <connectionStrings> <add

How can i retrieve a connectionString from a web.config file?

旧城冷巷雨未停 提交于 2020-01-05 03:59:13
问题 I am writing an client application in C# which will be supposed to change ConnectionString settings in a web.config file from another application I wrote. How can I achieve this goal? Is there a way to load the web.config file in my application and read/change its data object orientated? Or do I need to parse it as if beeing a complete 'unknown' XML file? 回答1: If you're doing this from another application, you can use the VirtualDirectoryMapping class: VirtualDirectoryMapping vdm = new