Inscrivez-vous ou connectez-vous pour rejoindre votre communauté professionnelle.
with any programming language!
When your application connects to a database(db) or a data file you let your provider (ADO/ADO.Net) utilize to do the job for you. This connection string contains the info that the provider need to know to be able to establish a connection to the related db or datafile.
You can see this C#.Net example which creates a SQLConnection and set the ConnectionString property before opening the connection:
private static void OpenSqlConnection() { string connectionString = GetConnectionString(); using (SqlConnection connection = new SqlConnection()) { connection.ConnectionString = connectionString; connection.Open(); Console.WriteLine("State: {0}", connection.State); Console.WriteLine("ConnectionString: {0}", connection.ConnectionString); } } static private string GetConnectionString() { // To avoid storing the connection string in your code, // you can retrieve it from a configuration file. return "Data Source=MSSQL1;Initial Catalog=AdventureWorks;" + "Integrated Security=true;"; }
Below example is using PHP:
$link = mysql_connect('localhost', 'mysql_user', 'mysql_password');if (!$link) { die('Could not connect: ' . mysql_error());}echo 'Connected successfully';mysql_close($link);
Connection String is simply a string that use to connect any type of Database to perform operaation on it. In any Language.
For Example:
Data Source=myServerAddress;Initial Catalog=myDataBase;Integrated Security=SSPI;
User ID=myDomain\\myUsername;Password=myPassword;
A connection string is a string that specifies information about a data source and the means of connecting to it. It is passed in code to an underlying driver or provider in order to initiate the connection.
Example
[SettingsBindableAttribute(true)]
public:
virtual property String^ ConnectionString {
String^ get () override;
void set (String^ value) override;
}
Exceptions:
ArgumentException -An invalid connection string argument has been supplied, or a required connection string argument has not been supplied.
For further refer these
http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlconnection.connectionstring(v=vs.110).aspx?cs-save-lang=1&cs-lang=csharp#code-snippet-1
Other Example in .NET
When your application connects to a database or a data file you let ADO or ADO.Net utilize a provider to do the job for you. The connection string contains the information that the provider need to know to be able to establish a connection to the database or the data file.
Reqrments
1.A connection string consists of a series of keyword - value pairs separated by semicolons (;)
2.The equal sign (=) connects each keyword and its value
Example: Key1=Value1;Key2=Value2;Key3=Value3;
Connection string is the sequence of characters that are used to connect to a database for example jdbc connection string for mysql database would look like 'jdbc:mysql://HOST/DATABASE com.mysql.jdbc.Driver'. HOST will be replaced by address of host machinne and DATABASE will be replaced by database name.
it is a string with special format contains credentials and other necessary information to create a connection with some resource.it is usually used with databases connection especially with oop programming languages.
Connection string is a user credentials to accress some sort of data (Database, website private pages...etc), it's called connection string because mostly it's passed to the server by one line of code.
والله اعلم اخي عبد الرحمن