memory variable

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Hrvoje Voda

    memory variable

    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




  • Sebastian Dau

    #2
    Re: memory variable

    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

    "Hrvoje Voda" <hrvoje.voda@lu atech.com> wrote in message
    news:d7k9un$h0t $1@ss405.t-com.hr...[color=blue]
    > 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
    >
    >
    >
    >
    >[/color]


    Comment

    • Hrvoje Voda

      #3
      Re: memory variable

      Here is a code.

      public class ULogon

      {

      string sConnString="";

      string UserName;

      string DomainName;

      Db db ;

      ArrayList arrayList = new ArrayList();



      public ULogon()

      {


      }

      public void SetConnectionSt ring(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;

      }

      }




      "Sebastian Dau" <sebastian.dau@ gmx.de> wrote in message
      news:429db38f$0 $297$4d4ebb8e@r ead-nat.news.de.uu. net...[color=blue]
      > 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
      >
      > "Hrvoje Voda" <hrvoje.voda@lu atech.com> wrote in message
      > news:d7k9un$h0t $1@ss405.t-com.hr...[color=green]
      >> 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
      >>
      >>
      >>
      >>
      >>[/color]
      >
      >[/color]


      Comment

      • Nicholas Paldino [.NET/C# MVP]

        #4
        Re: memory variable

        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.


        --
        - Nicholas Paldino [.NET/C# MVP]
        - mvp@spam.guard. caspershouse.co m

        "Hrvoje Voda" <hrvoje.voda@lu atech.com> wrote in message
        news:d7kc8h$n2a $1@ss405.t-com.hr...[color=blue]
        > Here is a code.
        >
        > public class ULogon
        >
        > {
        >
        > string sConnString="";
        >
        > string UserName;
        >
        > string DomainName;
        >
        > Db db ;
        >
        > ArrayList arrayList = new ArrayList();
        >
        >
        >
        > public ULogon()
        >
        > {
        >
        >
        > }
        >
        > public void SetConnectionSt ring(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;
        >
        > }
        >
        > }
        >
        >
        >
        >
        > "Sebastian Dau" <sebastian.dau@ gmx.de> wrote in message
        > news:429db38f$0 $297$4d4ebb8e@r ead-nat.news.de.uu. net...[color=green]
        >> 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
        >>
        >> "Hrvoje Voda" <hrvoje.voda@lu atech.com> wrote in message
        >> news:d7k9un$h0t $1@ss405.t-com.hr...[color=darkred]
        >>> 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
        >>>
        >>>
        >>>
        >>>
        >>>[/color]
        >>
        >>[/color]
        >
        >[/color]


        Comment

        Working...