-Using Sql ConnectionString=======================================
e.g:-
We need to store connectionString for a project, that will be used through the program,
so we can store such constant strings in config xml files
In .xml file we have a tag of <attributes> in which we can add our constant strings :-
<Attributes>
<Attribute name="connectionString" value="Data Source=(Server name);Initial Catalog=Database_name;Integrated Security=SSPI"/>
</Attributes>
OR we can add this is properties.Settings
e.g-Go to Properties of the project and select Settings in properties. Add your string as :
There are 4 columns in settings options as :-
Name:-connectionString (Name of your variable for which you are adding value in properties.settings)
Type:-Type of variable (e.g:-string,int)
Scope:-Application/user
Value:-Data Source=(Server name);Initial Catalog=Database_name;Integrated Security=SSPI (value of your const string)
//To use the connectionString from properties.Settings in your program :-
string connectionString = Properties.Settings.Default["connectionString"].ToString();
e.g:-
We need to store connectionString for a project, that will be used through the program,
so we can store such constant strings in config xml files
In .xml file we have a tag of <attributes> in which we can add our constant strings :-
<Attributes>
<Attribute name="connectionString" value="Data Source=(Server name);Initial Catalog=Database_name;Integrated Security=SSPI"/>
</Attributes>
OR we can add this is properties.Settings
e.g-Go to Properties of the project and select Settings in properties. Add your string as :
There are 4 columns in settings options as :-
Name:-connectionString (Name of your variable for which you are adding value in properties.settings)
Type:-Type of variable (e.g:-string,int)
Scope:-Application/user
Value:-Data Source=(Server name);Initial Catalog=Database_name;Integrated Security=SSPI (value of your const string)
//To use the connectionString from properties.Settings in your program :-
string connectionString = Properties.Settings.Default["connectionString"].ToString();
No comments:
Post a Comment