static public functions : asp.net c#
-
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
-
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
-
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
-
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
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.
-
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.
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
-
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
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.
-
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.
Thanks a lot....
Vijay V. Yash Softech