best way to save a value in C# App


i wondering whether better save value in global variable or save in invisibale label on c# windows application , retrieve whenever needed.

and question have sql conneciton. have form during form_load, calls 6-8 functions from classes. in each function, sql connection opened and  closed. i'm kind of concerned memory management , speed of application. read somewhere better not pass sqlconnection ref funciton. best way implement this?

 

thank you,

 

thanks responses. helpful. sqlconnection, still i'm little bit confuse. imagine have 2 classes , call method form_load:

...form_load(...)

class1.findname();

class1.findlastname();

class2.getinfo();

and in each method open , close each connection:

sqlconnection1.open();

using(sqlconnection1)

{...}

i'm calling 3 functions, different instances of sqlconnection opened , closed 3 times. connection string same i believe sqlconnection pool take care of still doesn't me. suggestion?

does hav document or link talks practices and bad habits/coding in c# programming? really helpful.

thanks help,

 

 

know looks bad, , if connection object implemented poorly, be.  if new connection database needed made each time called .open quite slow, behind scenes isn't going on.  it uses connection pooling.  what means connection object make connection database , hold onto it.  when calls .open, if connection unused, lets allocates object whoever called .open until done it.  when are, becomes available for else use.  by default, there 1 such connection maintained, if there enough use in multi-threaded application (or manually configure otherwise) can have number of connections in pool waiting used throughout application.


Visual Studio Languages  ,  .NET Framework  >  Visual C#



Comments

Popular posts from this blog

Azure DocumentDB Owner resource does not exist

How to fix error Msg 1801, Level 16, State 3, Line 1

How to Share webservice object to all user