Click here to Skip to main content
15,892,005 members
Home / Discussions / C#
   

C#

 
GeneralDataSet byte array storage Pin
Anfernius19-May-04 8:39
Anfernius19-May-04 8:39 
GeneralRe: DataSet byte array storage Pin
Dave Kreskowiak19-May-04 8:58
mveDave Kreskowiak19-May-04 8:58 
GeneralRe: DataSet byte array storage Pin
Heath Stewart19-May-04 9:04
protectorHeath Stewart19-May-04 9:04 
GeneralRe: DataSet byte array storage Pin
Dave Kreskowiak19-May-04 9:33
mveDave Kreskowiak19-May-04 9:33 
GeneralRe: DataSet byte array storage Pin
Heath Stewart19-May-04 9:36
protectorHeath Stewart19-May-04 9:36 
GeneralGlobal Variables in Visual C# Pin
Anonymous19-May-04 8:32
Anonymous19-May-04 8:32 
GeneralRe: Global Variables in Visual C# Pin
Heath Stewart19-May-04 8:55
protectorHeath Stewart19-May-04 8:55 
GeneralRe: Global Variables in Visual C# Pin
sreejith ss nair19-May-04 20:40
sreejith ss nair19-May-04 20:40 
what Stewart wrote is very good idea. Here i am giving one more little solution.If you want to use some values or variables like connection string and something else that you need entire phase of your application is simply stored in .config file.

.config file (app.config) is an xml file that you can add using Project > Add New Item menu. there choose xml file and rename it as app.config.

in that xml file file you can see somthing like this

<?xml version="1.0" encoding="utf-8" ?>

just add below mentioned code

<configuration>
<appSettings>
<add key="sourcename" value="YourDataSourceName" />
<add key="ConnectionString" value="your connection string " />
</appSettings>
<system.windows.forms jitDebugging="true" />
</configuration>





so finally you will get this much in your app.config file.

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="sourcename" value="YourDataSourceName" />
<add key="ConnectionString" value="your connection string " />
</appSettings>
<system.windows.forms jitDebugging="true" />
</configuration>





If you notice the <appsettings> tag then you will find

<add key="sourcename" value="YourDataSourceName" /> here <add key> will give a friendly name to your required data or value. eg. ConnectionString
and <value> is the actual value that you want in your programm.



How you will apply this in your forms or .cs file
-------------------------------------------------------

if you want to access the .config values you have to add a namespace called

using System.Configuration;

retriving value from .config

string Requiredvariable=ConfigurationSettings.AppSettings["ConnectionString"].ToString();

now you can use Requiredvariable to create database connection. you don't want to give the lengthy connection string value again and again in all forms or .cds file. You can reuse the Requiredvariable.
GeneralHelp reqd to Show Help .... Pin
fayazhsn19-May-04 8:25
fayazhsn19-May-04 8:25 
GeneralRe: Help reqd to Show Help .... Pin
Heath Stewart19-May-04 8:52
protectorHeath Stewart19-May-04 8:52 
GeneralRe: Help reqd to Show Help .... Pin
fayazhsn19-May-04 9:05
fayazhsn19-May-04 9:05 
GeneralRe: Help reqd to Show Help .... Pin
Heath Stewart19-May-04 9:43
protectorHeath Stewart19-May-04 9:43 
GeneralVS.NET Enterprise Architect vs. Professional Pin
Anonymous19-May-04 8:10
Anonymous19-May-04 8:10 
GeneralRe: VS.NET Enterprise Architect vs. Professional Pin
Grimolfr19-May-04 8:18
Grimolfr19-May-04 8:18 
GeneralRe: VS.NET Enterprise Architect vs. Professional Pin
Anonymous20-May-04 2:27
Anonymous20-May-04 2:27 
GeneralRe: VS.NET Enterprise Architect vs. Professional Pin
Dave Kreskowiak20-May-04 3:13
mveDave Kreskowiak20-May-04 3:13 
GeneralRe: VS.NET Enterprise Architect vs. Professional Pin
Anonymous20-May-04 7:37
Anonymous20-May-04 7:37 
GeneralRe: VS.NET Enterprise Architect vs. Professional Pin
Dave Kreskowiak20-May-04 11:52
mveDave Kreskowiak20-May-04 11:52 
GeneralRe: VS.NET Enterprise Architect vs. Professional Pin
Anonymous21-May-04 2:12
Anonymous21-May-04 2:12 
GeneralRe: VS.NET Enterprise Architect vs. Professional Pin
Anonymous25-May-04 19:26
Anonymous25-May-04 19:26 
Generalregd treeView control Pin
karteek19-May-04 8:06
karteek19-May-04 8:06 
GeneralRe: regd treeView control Pin
Dave Kreskowiak19-May-04 8:31
mveDave Kreskowiak19-May-04 8:31 
GeneralRe: regd treeView control Pin
Heath Stewart19-May-04 8:49
protectorHeath Stewart19-May-04 8:49 
GeneralRe: regd treeView control Pin
karteek19-May-04 9:04
karteek19-May-04 9:04 
GeneralRe: regd treeView control Pin
Heath Stewart19-May-04 9:08
protectorHeath Stewart19-May-04 9:08 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.