Eduardo Lorenzo 12-13-2006, 01:18 AM I have thee rpojects in one solution and all three have their own web.config file which contains my connection string(i think this is where I went wrong)
my Presentation Layer calls the web layer who in turn calls the data access layer to retrieve data.. which web.config is being used by by DAL class?
wayneph 12-13-2006, 07:10 AM Are all 3 Web Projects? I think that's where your problem lies. The Data Layer should probably be a Class Library. It shouldn't be a Web App. It will have an app.config file which serves the same purpose as the web.config file.
Unless of course your DAL is a Web Service? Then that is the web.config file that should contain the connection string.
I guess in short, the DAL should house the connection info for your database.
Eduardo Lorenzo 12-13-2006, 05:06 PM well I am using a "webservice" in a way.
the dal is a project which has other class files in it. Shoot, now that I look at it from afar, I believe my DAL and BLL are both in the same project!
Edit:
OK, after a short process of elimination, I found that the app is using the WebService's web.config. Now I am really confused.. does this mean that th webservice is also the DAL?
Eduardo Lorenzo 12-13-2006, 06:09 PM ok.. really getting confused with this. And I don't want any trouble with our Web, App, Network, and DB admins. I am developing this site almost alone and all the blame falls on me.
Now, will it cause problems(any kind) if the connection string is with the webservice? am already contemplating on the adverse effects of the webservice needing a bin folder.
am almost at the point of desperation.
here is my DataAccess class:
Imports System.Data
Imports System.Data.SqlClient
Public Class sqlserverhelper
Dim consqlCon As SqlConnection
Dim cmdsqlCmd As SqlCommand
Dim strErrorMsg As String
#Region "Class Properties"
Public ReadOnly Property CurrentParameters() As SqlClient.SqlParameterCollection
Get
Return cmdsqlCmd.Parameters
End Get
End Property
Public ReadOnly Property ErrorMessage() As String
Get
ErrorMessage = strErrorMsg
End Get
End Property
#End Region
#Region "New and Finalize Event Procedures"
Sub New(ByVal ConnectionString As String, ByVal CmdType As CommandType)
consqlCon = New SqlConnection(ConnectionString)
cmdsqlCmd = New SqlCommand("", consqlCon)
cmdsqlCmd.CommandType = CmdType
End Sub
Protected Overrides Sub Finalize()
If consqlCon.State <> ConnectionState.Closed Then consqlCon.Close()
consqlCon = Nothing
cmdsqlCmd = Nothing
strErrorMsg = Nothing
MyBase.Finalize()
End Sub
#End Region
#Region "sql Connection"
Public Function GetDataTable(ByVal CommandText As String, ByRef Target As DataTable) As Boolean
Dim RetTable As New DataTable
Dim dataAdatpter As SqlDataAdapter
cmdsqlCmd.CommandText = CommandText
dataAdatpter = New SqlDataAdapter(cmdsqlCmd)
Try
dataAdatpter.Fill(RetTable)
Target = RetTable
GetDataTable = True
strErrorMsg = ""
Catch ex As Exception
GetDataTable = False
strErrorMsg = ex.Message
Finally
cmdsqlCmd.Parameters.Clear()
dataAdatpter = Nothing
RetTable = Nothing
End Try
End Function
Public Function GetDataTable(ByVal CommandText As String, ByRef Target As DataSet) As Boolean
Dim RetTable As New DataSet
Dim dataAdatpter As SqlDataAdapter
cmdsqlCmd.CommandText = CommandText
dataAdatpter = New SqlDataAdapter(cmdsqlCmd)
Try
dataAdatpter.Fill(RetTable)
Target = RetTable
GetDataTable = True
strErrorMsg = ""
Catch ex As Exception
GetDataTable = False
strErrorMsg = ex.Message
Finally
cmdsqlCmd.Parameters.Clear()
dataAdatpter = Nothing
RetTable = Nothing
End Try
End Function
Public Function ExecuteNonQuerry(ByVal CommandText As String) As Boolean
cmdsqlCmd.CommandText = CommandText
Try
If consqlCon.State <> ConnectionState.Open Then consqlCon.Open()
cmdsqlCmd.ExecuteNonQuery()
ExecuteNonQuerry = True
strErrorMsg = ""
Catch ex As Exception
ExecuteNonQuerry = False
strErrorMsg = ex.Message
Finally
If consqlCon.State <> ConnectionState.Closed Then consqlCon.Close()
cmdsqlCmd.Parameters.Clear()
End Try
End Function
Public Sub AddParameter(ByVal Name As String, ByVal Value As Object)
Dim parsqlParam As SqlParameter
parsqlParam = New SqlParameter
With parsqlParam
.ParameterName = Name
.Direction = ParameterDirection.Input
.Value = Value
End With
cmdsqlCmd.Parameters.Add(parsqlParam)
parsqlParam = Nothing
End Sub
Public Sub AddParameter(ByVal Name As String, ByVal Value As Object, ByVal Direction As ParameterDirection)
Dim parsqlParam As SqlParameter
parsqlParam = New SqlParameter
With parsqlParam
.ParameterName = Name
.Direction = Direction
.Value = Value
End With
cmdsqlCmd.Parameters.Add(parsqlParam)
parsqlParam = Nothing
End Sub
#End Region
End Class
*i hope you guys like it
and this is how it is called by the BLL
Public Function gettranref(ByRef target As DataSet) As Boolean
Dim sqlhelp As New sqlserverhelper(connStrO, CommandType.StoredProcedure)
If sqlhelp.GetDataTable("sp_OBP_Tranrefno", target) Then
Return True
Else
errmsg = sqlhelp.ErrorMessage
Return False
End If
End Function
and this is how the BLL is called by the WebService
<WebMethod()> Public Function getTransactionHist(ByRef target As DataSet, ByVal cifnum As String) As Boolean
Dim myLayer As New datalayer.cls_Payment
Dim thiscoll As New System.Data.PropertyCollection
If myLayer.getTransactionHist(target, cifnum) Then
Return True
Else
Return False
End If
myLayer = Nothing
End Function
and this is how the webservice is used by the page (.aspx)
Private Sub popddl()
Dim libr As New obpwebservice.remitter
Dim tempDS As New DataSet
libr.getBranches(tempDS)
With Me.ddl_Branches
.DataSource = tempDS
.DataTextField = "brn_brnnames"
.DataValueField = "brn_brcode"
.DataBind()
End With
libr = Nothing
End Sub
the sqlServerHelper class and the cls_payment class resides in one project called Datalayer, and the Pages are in a separate project called UI and of course the webservice is in another project called myWebService.
They are all in one solution.
I need help to evaluate this "architecture" and how well it will be suited for the n-tier architecture. All comments shall be deeply appreciated. Am really sorry I can't put any of your names in the credits but all are really appreciated.
wayneph 12-14-2006, 08:14 AM If the Web Service is the DAL then that's where the connection string belongs. It sounds like you have one less tier than you were describing earlier. (I normally don't consider a SQL Helper type class as a tier by itself.) But that may be my own personal jaded view.
If the project works for you then you're doing alright. As far as what the Admins, and Network people will say, that all depends on them. In general, it looks like you've got an alright break out between the Data and the Presentation. If you have multiple apps that need the same data, you should be able to reuse it. I'd say that's a pretty good step...
Eduardo Lorenzo 12-14-2006, 05:29 PM OK,, so in a nutshell, it is OK to have the connection string in a webservice if it will serve as the DAL?
I have placed the Connection string in the DAL.
Last question:
is it OK to put the webservice "inside" the firewall?
wayneph 12-15-2006, 07:20 AM is it OK to put the webservice "inside" the firewall?
That depends. Will everything calling it be inside the firewall as well? If something external needs access to it, then it needs to be outside. Otherwise if all the users are internal, then inside the firewall will work.
Eduardo Lorenzo 12-15-2006, 08:42 PM That depends. Will everything calling it be inside the firewall as well? If something external needs access to it, then it needs to be outside. Otherwise if all the users are internal, then inside the firewall will work.
Then there is something definitely amiss in the architecture they had set up. They being the company.
This was my last discussion with one of the admins.
me: "Sir, will you allow me to have DLLs in our webserver? Because my webservice, when installed will definitely include a bin folder and a DLL referencing my DAL.
WeedMaster: "No problem, what we have is a webserver outside of the firewall, that's where you install your pages/UI. Then we have "another" web server inside the firewall and that's where you will install your webservice.
Me: "oh.. ok.."
Eduardo Lorenzo 12-18-2006, 04:30 PM That depends. Will everything calling it be inside the firewall as well? If something external needs access to it, then it needs to be outside. Otherwise if all the users are internal, then inside the firewall will work.
the thing is:
The network guys have asked me to design a "map" for my deployment.
it looks something like this where
00 - Main Website
01 - Internet(duhh.. :D)
02 - webserver
03 - application server
04 - DBServer
06 - Backup/Admin DB Server
07 - Intranet App Server
08 - Intranet "webserver"
12 and 13 - are Administrators form the Merchant and Client
with this configuration, is it OK to put the webservice in 02 along with all the .aspx files?
wayneph 12-19-2006, 07:47 AM If you're splitting it out, I'd probably put it on the application server. But that's just me.
In the environment I'm in our Web and Application servers are normally 1 in the same. We don't split them up, because there is very little overlap in projects so there isn't a lot that can be reused easially.
|