Data bond problem
-
HI I have made custom dropdown controls which load data from DB one page have many contols when pages is render each control load data from DB. Each control has its own connection close method If there are 5 controls on page on load FIVE time DB connection open & close this is implemented in control class its not good approach to open & close DB connection each time PLZ GIVE ME SOME GOOD SOLUTION thanks Irfan
-
HI I have made custom dropdown controls which load data from DB one page have many contols when pages is render each control load data from DB. Each control has its own connection close method If there are 5 controls on page on load FIVE time DB connection open & close this is implemented in control class its not good approach to open & close DB connection each time PLZ GIVE ME SOME GOOD SOLUTION thanks Irfan
Instead of opening & closing multiple times database connection you can define mutiple dataset based on number of controls and open a connection once in the load event populate all the datasets based on different sql query for populating different controls and once you finish then close the database connection. Now you can bind corresponding dataset to different controls. Hope this way you can avoid mutiple database trip and a performance gain as well Share knowledge to enhance your learning
-
HI I have made custom dropdown controls which load data from DB one page have many contols when pages is render each control load data from DB. Each control has its own connection close method If there are 5 controls on page on load FIVE time DB connection open & close this is implemented in control class its not good approach to open & close DB connection each time PLZ GIVE ME SOME GOOD SOLUTION thanks Irfan
Actally opening a connection that much is not a problem. But, I would say there is a problem with how your doing it. Have the class cache the data. A Dataset is overkill but some think its the best so cache the data how you want. I use classes personall;y and run from the word "Dataset". Its bulky and unneeded. But get the data once to limit roundtrips to the server. I you use a class hierachy each class would open its connection and grab the data. Since you can use a connection pool it shouldn't hurt the server too much. If this is a high traffic sight then other solution would be needed. Nick 1 line of code equals many bugs. So don't write any!!
-
Instead of opening & closing multiple times database connection you can define mutiple dataset based on number of controls and open a connection once in the load event populate all the datasets based on different sql query for populating different controls and once you finish then close the database connection. Now you can bind corresponding dataset to different controls. Hope this way you can avoid mutiple database trip and a performance gain as well Share knowledge to enhance your learning