Congratulations to all monthly winners of May 2013 !!! They have won INR 2900 cash and INR 27497 worth prize.
DotNetFunda.Com Logo
Twitter TwitterLinkedIn
YouTubeGoogle
 Online : 18359 |  Welcome, Guest!   Register  Login
 Home > Forums > VB.NET > handling db connection ...
Thiru

handling db connection

Replies: 2 | Posted by: Thiru on 6/2/2012 | Category: VB.NET Forums | Views: 527 | Status: [Member] | Points: 10  


Hi friends,

one small doubt.
in a loop i have to check the username availability in database for each id.

in this case: what will be the best practice:

1. open db connection in "check_availability_function" and close db there itself
so, as each & every time when the function call - its will open & close the db connection.

2. Open db connection before loops starts and pass the connection string to required functions...
(without opening & closing connection each time function ececutes)
and finally close the connection after loop ends.


Reply | Reply with attachment | Alert Moderator

 Responses below this adGet hundreds of .NET Tips and Tricks videos

 Replies

T.Saravanan
T.Saravanan  
Posted on: 6/3/2012 12:56:32 PM
Level: Silver | Status: [Member] [MVP] | Points: 25

Hi,

Try Disconnected architecture.....

For ex:


SqlConnection sqlConn = new SqlConnection(.....);
SqlDataAdapter da = new SqlDataAdapter("Select * from table", sqlconn);
DataTable dt = new DataTable();
da.Fill(dt);


Refer the below links for more reference...
http://csharp.net-informations.com/ado.net/ado.net-data-access-architecture.htm
http://www.programcall.com/3/adonet/disconnected-architecture-in-adonet.aspx


Thanks,
T.Saravanan

Thiru, if this helps please login to Mark As Answer. | Reply | Alert Moderator 

Ajay.Kalol
Ajay.Kalol  
Posted on: 6/3/2012 11:51:14 PM
Level: Starter | Status: [Member] | Points: 25

Try Disconnected DataBase Architecture,

Retrieve all data in DataTable and then Make a loop on that Table,

It is better then Access Database all time in loop,
Also it will increase performance of your code.

if need further help? then put comment on this post

Enjoy.......

http://ajaypatelfromsanthal.blogspot.in

Thiru, if this helps please login to Mark As Answer. | Reply | Alert Moderator 

Reply - Please login to reply


Click here to login & reply

About Us | Contact Us | The Team | Advertise | Software Development | Write for us | Testimonials | Privacy Policy | Terms of Use | Link Exchange | Members | Go Top
General Notice: If you find plagiarised (copied) contents on this page, please let us know the original source along with your correct email id (to communicate) for further action.
Copyright © DotNetFunda.Com. All Rights Reserved. Copying or mimicking the site design and layout is prohibited. Logos, company names used here if any are only for reference purposes and they may be respective owner's right or trademarks. | 6/19/2013 5:04:45 AM