memory variable

  • Thread starter Thread starter Hrvoje Voda
  • Start date Start date
H

Hrvoje Voda

public bool Logon()

{

if (db!=null)

{

Login lg = new Login (db);

lg.ShowDialog ();

UserName = lg.UserName ;

DomainName = lg.DomainName ;

return true;

}

else

return false;

}



I'm using this code to get UserName and DomainName from a dialog.

It is a dll file.

But, when I call another function in that same dll UserName and DomainName
variables are empty!

How can I save there values so that I can use it in another functions?



Hrcko
 
Where (in the same class as Logon() ??? ) is username and domain name
declared?
Do you re-initialize these fields accidentially right after the Login Call?

Some more wrapping code of Login() is needed to provide you help.

Greets, Sebastian Dau
 
Here is a code.

public class ULogon

{

string sConnString="";

string UserName;

string DomainName;

Db db ;

ArrayList arrayList = new ArrayList();



public ULogon()

{


}

public void SetConnectionString(string sConnString)

{

db = new Db (sConnString);

}

public bool Logon()

{

if (db!=null)

{

Login lg = new Login (db);

lg.ShowDialog ();

UserName = lg.UserName ;

DomainName = lg.DomainName ;

return true;

}

else

return false;

}

}
 
Hrvoje,

Are you using new instances of the class each time? If so, then you
will have to store those values outside of the class, or in static
variables.

Hope this helps.
 
Back
Top