Connection Strings C# with Example



Connection Strings C# with Example

A Connection String is a string that specifies information about a particular data source and how to go about 
connecting to it by storing credentials, locations, and other information. 
Server=myServerAddress;Database=myDataBase;User Id=myUsername;Password=myPassword; 
Storing Your Connection String 
Typically, a connection string will be stored within a configuration file (such as an app.config or web.config within 
ASP.NET applications). The following is an example of what a local connection might look like within one of these 
files : 
 
 
 
 
 
 
This will allow your application to access the connection string programmatically through WidgetsContext. 
Although both Integrated Security=SSPI and Integrated Security=True perform the same function;Integrated 
Security=SSPI is preferred since works with both SQLClient & OleDB provider where as Integrated 
Security=true throws an exception when used with the OleDb provider. 
Different Connections for Different Providers 
Each data provider (SQL Server, MySQL, Azure, etc.) all feature their own flavor of syntax for their connection strings 
and expose different available properties. ConnectionStrings.com is an incredibly useful resource if you are unsure 
about what yours should look like. 

0 Comment's

Comment Form