Results 1 to 5 of 5

Thread: [RESOLVED] static on web vs windows

  1. #1

    Thread Starter
    Fanatic Member popskie's Avatar
    Join Date
    Jul 2005
    Location
    In my chair
    Posts
    666

    Resolved [RESOLVED] static on web vs windows

    Hi ,

    Can anyone explain what is the difference between web app and windows app using static variable in terms of multiuser access?


    Thanks,

    Popskie

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: static on web vs windows

    There is no difference. A static member is a member of a class, not an instance of a class.

    The difference that you perceive is that with a Windows application there would rarely be more than one instance of your application running on a system at once. With a Web app the same system is serving multiple users much of the time, so your static members are shared by all those users.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Fanatic Member popskie's Avatar
    Join Date
    Jul 2005
    Location
    In my chair
    Posts
    666

    Re: static on web vs windows

    I approved of what you said JM. Thanks

    So, if posible its better to avoid using static in a web app. Am I right? Actually JM this app is already live in production but where lucky that until now its only one user used this site.hehehe
    Again thanks.

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: static on web vs windows

    I don't know exactly how you're using it but many people abuse the static key word. If you've assigned a connection to a static variable in a class that may be used by more than one caller then that's a problem. A static variable is one for which there is, and should only be, one instance for the entire class. If you're making multiple connections then it's not logical that there should only be a single connection object.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  5. #5

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width