all groups > dotnet distributed apps > december 2005 >
You're in the

dotnet distributed apps

group:

Reusing code across multiple projects in distr app


Reusing code across multiple projects in distr app Ross
12/13/2005 4:27:01 AM
dotnet distributed apps:
Hi folks

I am building this distributed app that has a number of Web Service Projects.

A common task is to connect to a DB with code that looks like this:

Dim cn As SqlConnection
Dim strInfo As String

strInfo = "server=(local);Persist Security
Info=False;pwd=;Integrated
Security=SSPI;database=FusionCommunityVolunteerService;Connect Timeout=30"

Try
cn = New SqlConnection
With cn
.ConnectionString = strInfo
.Open()
End With

Return cn

Catch ex As Exception

Finally

If cn.State <> Data.ConnectionState.Closed Then
cn.Close()
cn.Dispose()
End If
End Try

I was thinking that it would be good both from a programming time viewpoint
and also in terms of code maintainability if I could have a func procedure
that does exactly that and could be called from any procedure in any of the
projects in the Solution.

What is the best way to do this? Any advice would be muchly appreciated.

Kind regards

RE: Reusing code across multiple projects in distr app binvij
12/13/2005 5:23:03 AM
Hi Ross,

I believe, for the said scenario, Data Access Application blocks will be a
viable option.

thnks
--
Bindesh Vijayan
MCP [ASP.NET]


[quoted text, click to view]
RE: Reusing code across multiple projects in distr app Ross
12/13/2005 11:27:03 AM
Thanks Bindesh

So, how do I do that?

Could I just create a Class Module and create the procedure in that module
using the "Friend" keyword? Or would there be a better approach?

Also, in respect to the "Finally" section in the Try ... End Try block, is
this part OK:

[quoted text, click to view]

Kind regards

Ross Petersen


[quoted text, click to view]
AddThis Social Bookmark Button