Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. static public functions : asp.net c#

static public functions : asp.net c#

Scheduled Pinned Locked Moved ASP.NET
csharpasp-netdatabase
7 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    VijayVishwakarma
    wrote on last edited by
    #1

    Hi, I have a class file: dbtest and a have create a static public function that returns values from database. Since its an static public function so i can access it as dbsale.function(). Now I wanted to know the disadvantages of this approach when say there are some 1000 call at a time for this function. I have searched a lot and found examples of using static public functions but no where I found it to be used for calling a database operation. Thanks in advance. Regards

    Vijay V. Yash Softech

    A E 2 Replies Last reply
    0
    • V VijayVishwakarma

      Hi, I have a class file: dbtest and a have create a static public function that returns values from database. Since its an static public function so i can access it as dbsale.function(). Now I wanted to know the disadvantages of this approach when say there are some 1000 call at a time for this function. I have searched a lot and found examples of using static public functions but no where I found it to be used for calling a database operation. Thanks in advance. Regards

      Vijay V. Yash Softech

      A Offline
      A Offline
      anilpal
      wrote on last edited by
      #2

      hi, Now what u want?

      Regards Anil Pal

      V 1 Reply Last reply
      0
      • A anilpal

        hi, Now what u want?

        Regards Anil Pal

        V Offline
        V Offline
        VijayVishwakarma
        wrote on last edited by
        #3

        I wanted to know the disadvantages of this approach when say there are some 1000 call at a time for this function.

        Vijay V. Yash Softech

        1 Reply Last reply
        0
        • V VijayVishwakarma

          Hi, I have a class file: dbtest and a have create a static public function that returns values from database. Since its an static public function so i can access it as dbsale.function(). Now I wanted to know the disadvantages of this approach when say there are some 1000 call at a time for this function. I have searched a lot and found examples of using static public functions but no where I found it to be used for calling a database operation. Thanks in advance. Regards

          Vijay V. Yash Softech

          E Offline
          E Offline
          Eytukan
          wrote on last edited by
          #4

          I think I can equate this multi-user thing to a multithreaded environment. You can use public static functions, there will be no problem. But if you are using static objects inside your function, then there's a one. There are big chances your static objects get overwritten with calls from other clients. If you are using local objects or instance members inside the function, then there wouldn't be any problem. This is all a guess. I haven't tried this in Asp.net ;)

          Starting to think people post kid pics in their profiles because that was the last time they were cute - Jeremy.

          V 1 Reply Last reply
          0
          • E Eytukan

            I think I can equate this multi-user thing to a multithreaded environment. You can use public static functions, there will be no problem. But if you are using static objects inside your function, then there's a one. There are big chances your static objects get overwritten with calls from other clients. If you are using local objects or instance members inside the function, then there wouldn't be any problem. This is all a guess. I haven't tried this in Asp.net ;)

            Starting to think people post kid pics in their profiles because that was the last time they were cute - Jeremy.

            V Offline
            V Offline
            VijayVishwakarma
            wrote on last edited by
            #5

            Thanks ViNic for your reply....... Can u focus on the following code is this one is correct? BinaryTree.cs file inside appcode public class BinaryTree { public static ArrayList dlist = new ArrayList(); public static void FetchDownlineID(long uid) { BinaryTree bt = new BinaryTree(); bt = BinaryTree.fetchIdInfo(uid);//fetches user info if (bt.Aid > 0) { dlist.Add(bt.Aid); BinaryTree.FetchDownlineID(bt.Aid); } if (bt.Bid > 0) { dlist.Add(bt.Bid); BinaryTree.FetchDownlineID(bt.Bid); } if (bt.Cid > 0) { dlist.Add(bt.Cid); BinaryTree.FetchDownlineID(bt.Cid); } } } now this function is called on pageload as user's open page & result is bind to gridview... as follows---------- public partial class User_DownlineLists : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { bindGridView(); } protected void bindGridView() { if (Session["User"] != null) { long id = UserDetails.FetchUserId(Session["User"].ToString()); BinaryTree.dlist.Clear(); BinaryTree.FetchDownlineID(id); Sort();//this function sort list datewise GridView1.DataSource = BinaryTree.dlist; GridView1.DataBind(); } else { Response.Redirect("~/Home.aspx"); } } }

            Vijay V. Yash Softech

            E 1 Reply Last reply
            0
            • V VijayVishwakarma

              Thanks ViNic for your reply....... Can u focus on the following code is this one is correct? BinaryTree.cs file inside appcode public class BinaryTree { public static ArrayList dlist = new ArrayList(); public static void FetchDownlineID(long uid) { BinaryTree bt = new BinaryTree(); bt = BinaryTree.fetchIdInfo(uid);//fetches user info if (bt.Aid > 0) { dlist.Add(bt.Aid); BinaryTree.FetchDownlineID(bt.Aid); } if (bt.Bid > 0) { dlist.Add(bt.Bid); BinaryTree.FetchDownlineID(bt.Bid); } if (bt.Cid > 0) { dlist.Add(bt.Cid); BinaryTree.FetchDownlineID(bt.Cid); } } } now this function is called on pageload as user's open page & result is bind to gridview... as follows---------- public partial class User_DownlineLists : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { bindGridView(); } protected void bindGridView() { if (Session["User"] != null) { long id = UserDetails.FetchUserId(Session["User"].ToString()); BinaryTree.dlist.Clear(); BinaryTree.FetchDownlineID(id); Sort();//this function sort list datewise GridView1.DataSource = BinaryTree.dlist; GridView1.DataBind(); } else { Response.Redirect("~/Home.aspx"); } } }

              Vijay V. Yash Softech

              E Offline
              E Offline
              Eytukan
              wrote on last edited by
              #6

              No, This looks truly bad to me.

              VijayVishwakarma wrote:

              public static ArrayList dlist = new ArrayList(); public static void FetchDownlineID(long uid)

              You might have read a "rant" from me just above your message. That says why you should not do it. Though every member would create a new object of your BianryTree, it's dlist would be shared.

              VijayVishwakarma wrote:

              if (bt.Aid > 0) { dlist.Add(bt.Aid);

              When one client does the above code, Another client could potentially execute the below code. BinaryTree.dlist.Clear();. You get the idea?

              Starting to think people post kid pics in their profiles because that was the last time they were cute - Jeremy.

              V 1 Reply Last reply
              0
              • E Eytukan

                No, This looks truly bad to me.

                VijayVishwakarma wrote:

                public static ArrayList dlist = new ArrayList(); public static void FetchDownlineID(long uid)

                You might have read a "rant" from me just above your message. That says why you should not do it. Though every member would create a new object of your BianryTree, it's dlist would be shared.

                VijayVishwakarma wrote:

                if (bt.Aid > 0) { dlist.Add(bt.Aid);

                When one client does the above code, Another client could potentially execute the below code. BinaryTree.dlist.Clear();. You get the idea?

                Starting to think people post kid pics in their profiles because that was the last time they were cute - Jeremy.

                V Offline
                V Offline
                VijayVishwakarma
                wrote on last edited by
                #7

                Thanks a lot....

                Vijay V. Yash Softech

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups