Link to home
Start Free TrialLog in
Avatar of sainavya1215
sainavya1215

asked on

3 Tier application Connection Object/NT authentication

hi,

I want to implement 3 tier MULTI USER application in visual basic(Client/Dll/Db) . I want to implement windows Authentication
with sqlserver2000 as Database

Connection string is :

dim strsql as string="Provider=sqloledb;database=Test;server=computer1;Trusted_connection=True"

How should the connection object be written in the middleLayer.

Lets say I have several functions in my DLL's which interact with the database.
Should I design in such a way that in each and every function open database serve data to the client
and close it Or should i go for global connection .......

Could it be explained in detail which technique to follow and why with a simple example

Thanks in advance
Avatar of DarkoLord
DarkoLord
Flag of Slovenia image

Hi,
I would make a class for database connection/manipulation/etc and call .Open and .Close methods in every function so there would be as little code as possible because for a global connection you would always have to check if a connection is still "on" (you never know when you might get disconnected) and if not you would have to estabilish it again and so on...

Just a thought :))

Darko
Avatar of TILL
TILL

Business Logic usually performes multiple operations on a database. If you use SQL Server, I would recomend you to create a dynamic connection pool manager and create a stored procedure on the server for each business rules that you have in your application. The advantage of this approach is that whenever a field is added tio your database, you can anly update the stored procedures without rewriting important parts of the application, and regarding the pool manager is that you minimize the overload and the roundtrips to the server.

If you need more details, just ask.
Best of luck, TILL.
Avatar of sainavya1215

ASKER

1)

ok lets say I have  Db.open and db.close(finally) in all my functions in my DLL's . Lets say 4 users have connected to the application. Will it contain 4 connections or? How can we analyze this. MoreOver if we are going to implement NTauthentication will this technique work.. Isnt it that connection open and close each and every time effect the performance. If opening and closing will the UserContext be mainatianed(NTauthentication) as sqlserver is on different box.  


2) If its global conn and we just pass connObj to functions instead of opening and closing it again and again . How would this work lets say 4 users are connected. How many connections would be created. Will the connection be opened only once Or 4 times.

I need to understand how it works in a multiUser environement. If u say about connection pooling how can it be implemented in the 1st scenario as i heard Pooling doesnot work in NTauthentication (though we are doing it right using open and close connection in all our functions)

In some of the Doc's it says "OPEN CONN late close early"  in some it says open/close is performance loss at DB level..........I really dont understand instead confused which to use to IMPLEMENT authentication / Pooling  etc and how it works in both scenarios(how many connections are created etc) are multi User environment
Connecting and disconnecting every time is not a performance issue as these things work very fast...

Darko
ASKER CERTIFIED SOLUTION
Avatar of born4code
born4code

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ok fine.. Actually I am implementing Remoting(Dcom) u can say where i have my DLL's hosted in IIS... IIS and sqlserver2000 reside on different box. ie all the dll's are in central location. Now clients connect  to that box.

In this type of scenario which is best to use to achieve NT authentication. currently I am having the following structure


i have a connection class (function which retuns connection) Lets say

public function OpenConn() as connection

return connection
end function

public function connClose()
close connection
end function

In all my dlls I am using stored proc's..........I open the conn in each and every function and close it ....So every function call opens and closes connection....

My doubts are :1)  In distributed com environment is this right approach..........How can the user context be maintained when i am open and closing functions in each and every function.I heard that open conn in every function is not good (But doc's say open conn late and close it early ie what i am followng now right)

2) In some other doc's it says when ur having a remote DB better u use a global connection........

Hope its clear what I want to achieve. Considering its multiUserapp/implementation of NT authentication etc Pls advice me what would be the best and WHY?

Thanks in advance

infact its .NET remoting scenario
I have the understanding that your application will complete authentication once when the connection is established.  After the connection has been established, you do not have to keep "repeating" authentication.  Is this correct?
My question is


In my current model i  am serveral functions in my Dlls which interact with the database. Now.. I have a connection class which  has 2 functins 1) Opens connection
2) closes connection


So in each and every function in my Dll i   open and close function after data is served. Now..I am using Windows authentication ......... Lets say a user connects Now user is authenticated sucessfully and connection is CLOSED........1) Will the user context be maintained or not???

  how would u maintain userContext when u open a connection and Close it ...... So i wanted to make sure that what i had done is right or not.... I know that A token  is sent first when connecting To db to authenticate the user but when we close connection wil the UserContext be identified OR SHOULD WE USE A GLOBAL CONNECTION and remain always connection to maintain userContext