3
How to establish a connection to the Northwind database using App.config
and ADO.NET?
3
How to establish a connection to the Northwind database using App.config
and ADO.NET?
10
I think this is what you want:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<connectionStrings>
<add name="conn" connectionString="Data Source=.;Initial Catalog=Northwind;IntegratedSecurity=True" providerName="System.Data.SqlClient"/>
</connectionStrings>
</configuration>
Code:
using System.Data.SqlClient;
using System.Configuration;
public class Programa {
public static void Main() {
conn = new SqlConnection(ConfigurationManager.ConnectionStrings["conn"].ConnectionString);
conn.Open();
}
}
Browser other questions tagged c# .net sql-server ado.net app.config
You are not signed in. Login or sign up in order to post.