Data Layer, Business logic layer help
Data Layer, Business logic layer help
am 10.10.2007 23:36:18 von Sal
Hello,
I have a Dataset that I have table adapters in I designed using the designer
(DataLayer). I have a business logic layer that immulates the DataLayer
which may/may not have additional logic in. My business classes are, of
course, decorated with the:
attribute.
So, I drop a GridView on a webform and set its datasource to an
ObjectDatasource which in turn is using one of my business logic classes.
I'm noticing something I find odd in one of my Gridviews. I have it's
datasource set as an object data source which is using a business logic
class. I set the update method to an update method in my business logic
class and the code does indeed step into this update function when after I
have clicked the Edit button, edit data and then click the Update button on
the GridView. So, there the line in this Update function that looks like
this:
Return Adapter.UpdateCntyAssetsAssetManagement(ant, nlca, ar, an,
cntyAssetsId)
What I find odd is if I stop debugging before the above line, the data in
the database still gets changed.
Can anyone tell me why this might occur?
If this is S.O.P. (standard operating proceedure), what could possibly be
the purpose of creating a business logic layer to begin with?
Thoughts?
I have a couple of other issues with this GridView as well but thought I
should get this one ironed out first.
Thanks
SAL
Re: Data Layer, Business logic layer help
am 11.10.2007 08:33:05 von olrbengax
On Oct 10, 5:36 pm, "SAL" wrote:
> Hello,
> I have a Dataset that I have table adapters in I designed using the designer
> (DataLayer). I have a business logic layer that immulates the DataLayer
> which may/may not have additional logic in. My business classes are, of
> course, decorated with the:
>
> attribute.
>
> So, I drop a GridView on a webform and set its datasource to an
> ObjectDatasource which in turn is using one of my business logic classes.
>
> I'm noticing something I find odd in one of my Gridviews. I have it's
> datasource set as an object data source which is using a business logic
> class. I set the update method to an update method in my business logic
> class and the code does indeed step into this update function when after I
> have clicked the Edit button, edit data and then click the Update button on
> the GridView. So, there the line in this Update function that looks like
> this:
>
> Return Adapter.UpdateCntyAssetsAssetManagement(ant, nlca, ar, an,
> cntyAssetsId)
>
> What I find odd is if I stop debugging before the above line, the data in
> the database still gets changed.
> Can anyone tell me why this might occur?
> If this is S.O.P. (standard operating proceedure), what could possibly be
> the purpose of creating a business logic layer to begin with?
>
> Thoughts?
> I have a couple of other issues with this GridView as well but thought I
> should get this one ironed out first.
> Thanks
>
> SAL
What's in the rest of the Update function in the BLL? Have you tried
commenting that line out and seeing what happens?
Oliver
RE: Data Layer, Business logic layer help
am 11.10.2007 11:26:45 von stcheng
Hi SA,
I think this is certainly not the expected behavior. I'm wondering whether
there is some component specifcy or project specific things that result to
this problem. Would you try use a very simpler DataAccess class to test
the behavior or your can create a different project for test also.
Sincerely,
Steven Cheng
Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
>From: "SAL"
>Subject: Data Layer, Business logic layer help
>Date: Wed, 10 Oct 2007 14:36:18 -0700
>
>Hello,
>I have a Dataset that I have table adapters in I designed using the
designer
>(DataLayer). I have a business logic layer that immulates the DataLayer
>which may/may not have additional logic in. My business classes are, of
>course, decorated with the:
>
> attribute.
>
>So, I drop a GridView on a webform and set its datasource to an
>ObjectDatasource which in turn is using one of my business logic classes.
>
>I'm noticing something I find odd in one of my Gridviews. I have it's
>datasource set as an object data source which is using a business logic
>class. I set the update method to an update method in my business logic
>class and the code does indeed step into this update function when after I
>have clicked the Edit button, edit data and then click the Update button
on
>the GridView. So, there the line in this Update function that looks like
>this:
>
>Return Adapter.UpdateCntyAssetsAssetManagement(ant, nlca, ar, an,
>cntyAssetsId)
>
>What I find odd is if I stop debugging before the above line, the data in
>the database still gets changed.
>Can anyone tell me why this might occur?
>If this is S.O.P. (standard operating proceedure), what could possibly be
>the purpose of creating a business logic layer to begin with?
>
>Thoughts?
>I have a couple of other issues with this GridView as well but thought I
>should get this one ironed out first.
>Thanks
>
>SAL
>
>
>
Re: Data Layer, Business logic layer help
am 11.10.2007 18:13:07 von Sal
I set up one of my other classes to test this out Steven. I created the
update query in the datatable using the designer, added the update method to
the business class, created a new web page, added a GridView and an object
data source set to my business class, put a break point on the line that
should do the actual update, ran it in debug mode, clicked Edit, changed a
value and then clicked update and the code executed as expected and broke on
the line that should do the updating. When the code was stopped at that
line, I clicked the stop debugging button on the tool bar and the database
was indeed updated to the new value I set. While the code was stopped on the
update line, I checked the database and the values had not been changed at
that point. So, this is happening after the stop debugging button has been
clicked in the VS 2005 user interface.
Here's the code for my business class that I used for test. I do not believe
it's anything in the business class that's causing this. I think it's a bug
in VS 2005???
Imports Microsoft.VisualBasic
Imports System.Data.SqlClient
Imports System.Data
Imports CatsDsTableAdapters
_
Public Class PropertyTypesBLL
Private ptTA As CntyPropertyTypesTableAdapter
Protected ReadOnly Property Adapter() As CntyPropertyTypesTableAdapter
Get
If ptTA Is Nothing Then
ptTA = New CntyPropertyTypesTableAdapter
End If
Return ptTA
End Get
End Property
True)> _
Public Function GetPropertyTypes() As CatsDs.CntyPropertyTypesDataTable
Return Adapter.GetPropertyTypes
End Function
False)> _
Public Function GetPropertyTypeByPropertyTypeId(ByVal propertyTypeId As
Integer) As CatsDs.CntyPropertyTypesDataTable
Return Adapter.GetPropertyTypeByPropertyTypeId(propertyTypeId)
End Function
True)> _
Public Function UpdateCntyPropertyType(ByVal propertyType As String,
ByVal propertyTypeId As Integer) As Boolean
Return Adapter.UpdateCntyPropertyType(propertyType, propertyTypeId)
End Function
End Class
Steve
"Steven Cheng[MSFT]" wrote in message
news:mp7Ogj%23CIHA.360@TK2MSFTNGHUB02.phx.gbl...
> Hi SA,
>
> I think this is certainly not the expected behavior. I'm wondering whether
> there is some component specifcy or project specific things that result to
> this problem. Would you try use a very simpler DataAccess class to test
> the behavior or your can create a different project for test also.
>
> Sincerely,
>
> Steven Cheng
>
> Microsoft MSDN Online Support Lead
>
>
> This posting is provided "AS IS" with no warranties, and confers no
> rights.
> --------------------
>>From: "SAL"
>>Subject: Data Layer, Business logic layer help
>>Date: Wed, 10 Oct 2007 14:36:18 -0700
>
>>
>>Hello,
>>I have a Dataset that I have table adapters in I designed using the
> designer
>>(DataLayer). I have a business logic layer that immulates the DataLayer
>>which may/may not have additional logic in. My business classes are, of
>>course, decorated with the:
>>
>> attribute.
>>
>>So, I drop a GridView on a webform and set its datasource to an
>>ObjectDatasource which in turn is using one of my business logic classes.
>>
>>I'm noticing something I find odd in one of my Gridviews. I have it's
>>datasource set as an object data source which is using a business logic
>>class. I set the update method to an update method in my business logic
>>class and the code does indeed step into this update function when after I
>>have clicked the Edit button, edit data and then click the Update button
> on
>>the GridView. So, there the line in this Update function that looks like
>>this:
>>
>>Return Adapter.UpdateCntyAssetsAssetManagement(ant, nlca, ar, an,
>>cntyAssetsId)
>>
>>What I find odd is if I stop debugging before the above line, the data in
>>the database still gets changed.
>>Can anyone tell me why this might occur?
>>If this is S.O.P. (standard operating proceedure), what could possibly be
>>the purpose of creating a business logic layer to begin with?
>>
>>Thoughts?
>>I have a couple of other issues with this GridView as well but thought I
>>should get this one ironed out first.
>>Thanks
>>
>>SAL
>>
>>
>>
>
Re: Data Layer, Business logic layer help
am 16.10.2007 04:48:48 von stcheng
Thanks for your followup SAL,
I think the cases you provided should be a quite typical one, I'll perform
some test on my side and let you know the result.
Sincerely,
Steven Cheng
Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
>From: "SAL"
>References:
>Subject: Re: Data Layer, Business logic layer help
>Date: Thu, 11 Oct 2007 09:13:07 -0700
>
>I set up one of my other classes to test this out Steven. I created the
>update query in the datatable using the designer, added the update method
to
>the business class, created a new web page, added a GridView and an object
>data source set to my business class, put a break point on the line that
>should do the actual update, ran it in debug mode, clicked Edit, changed a
>value and then clicked update and the code executed as expected and broke
on
>the line that should do the updating. When the code was stopped at that
>line, I clicked the stop debugging button on the tool bar and the database
>was indeed updated to the new value I set. While the code was stopped on
the
>update line, I checked the database and the values had not been changed at
>that point. So, this is happening after the stop debugging button has been
>clicked in the VS 2005 user interface.
>Here's the code for my business class that I used for test. I do not
believe
>it's anything in the business class that's causing this. I think it's a
bug
>in VS 2005???
>
>Imports Microsoft.VisualBasic
>Imports System.Data.SqlClient
>Imports System.Data
>Imports CatsDsTableAdapters
>
> _
>Public Class PropertyTypesBLL
> Private ptTA As CntyPropertyTypesTableAdapter
>
> Protected ReadOnly Property Adapter() As CntyPropertyTypesTableAdapter
> Get
> If ptTA Is Nothing Then
> ptTA = New CntyPropertyTypesTableAdapter
> End If
> Return ptTA
> End Get
> End Property
>
>
bjectMethodType.Select,
>True)> _
> Public Function GetPropertyTypes() As CatsDs.CntyPropertyTypesDataTable
> Return Adapter.GetPropertyTypes
> End Function
>
>
bjectMethodType.Select,
>False)> _
> Public Function GetPropertyTypeByPropertyTypeId(ByVal propertyTypeId As
>Integer) As CatsDs.CntyPropertyTypesDataTable
> Return Adapter.GetPropertyTypeByPropertyTypeId(propertyTypeId)
> End Function
>
>
bjectMethodType.Update,
>True)> _
> Public Function UpdateCntyPropertyType(ByVal propertyType As String,
>ByVal propertyTypeId As Integer) As Boolean
> Return Adapter.UpdateCntyPropertyType(propertyType, propertyTypeId)
> End Function
>End Class
>
>
>Steve
>"Steven Cheng[MSFT]" wrote in message
>news:mp7Ogj%23CIHA.360@TK2MSFTNGHUB02.phx.gbl...
>> Hi SA,
>>
>> I think this is certainly not the expected behavior. I'm wondering
whether
>> there is some component specifcy or project specific things that result
to
>> this problem. Would you try use a very simpler DataAccess class to test
>> the behavior or your can create a different project for test also.
>>
>> Sincerely,
>>
>> Steven Cheng
>>
>> Microsoft MSDN Online Support Lead
>>
>>
>> This posting is provided "AS IS" with no warranties, and confers no
>> rights.
>> --------------------
>>>From: "SAL"
>>>Subject: Data Layer, Business logic layer help
>>>Date: Wed, 10 Oct 2007 14:36:18 -0700
>>
>>>
>>>Hello,
>>>I have a Dataset that I have table adapters in I designed using the
>> designer
>>>(DataLayer). I have a business logic layer that immulates the DataLayer
>>>which may/may not have additional logic in. My business classes are, of
>>>course, decorated with the:
>>>
>>> attribute.
>>>
>>>So, I drop a GridView on a webform and set its datasource to an
>>>ObjectDatasource which in turn is using one of my business logic classes.
>>>
>>>I'm noticing something I find odd in one of my Gridviews. I have it's
>>>datasource set as an object data source which is using a business logic
>>>class. I set the update method to an update method in my business logic
>>>class and the code does indeed step into this update function when after
I
>>>have clicked the Edit button, edit data and then click the Update button
>> on
>>>the GridView. So, there the line in this Update function that looks like
>>>this:
>>>
>>>Return Adapter.UpdateCntyAssetsAssetManagement(ant, nlca, ar, an,
>>>cntyAssetsId)
>>>
>>>What I find odd is if I stop debugging before the above line, the data in
>>>the database still gets changed.
>>>Can anyone tell me why this might occur?
>>>If this is S.O.P. (standard operating proceedure), what could possibly be
>>>the purpose of creating a business logic layer to begin with?
>>>
>>>Thoughts?
>>>I have a couple of other issues with this GridView as well but thought I
>>>should get this one ironed out first.
>>>Thanks
>>>
>>>SAL
>>>
>>>
>>>
>>
>
>
>
Re: Data Layer, Business logic layer help
am 18.10.2007 10:59:35 von stcheng
Hi SAL,
After some testing, I've repro this problem and got the same behavior as
you mentioned. Currently I'll do some further research on this and will let
you know if I get any new update.
Sincerely,
Steven Cheng
Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
>From: stcheng@online.microsoft.com (Steven Cheng[MSFT])
>Organization: Microsoft
>Date: Tue, 16 Oct 2007 02:48:48 GMT
>Subject: Re: Data Layer, Business logic layer help
>
>Thanks for your followup SAL,
>
>I think the cases you provided should be a quite typical one, I'll perform
>some test on my side and let you know the result.
>
>Sincerely,
>
>Steven Cheng
>
>Microsoft MSDN Online Support Lead
>
>
>This posting is provided "AS IS" with no warranties, and confers no rights.
>--------------------
>>From: "SAL"
>>References:
>
>>Subject: Re: Data Layer, Business logic layer help
>>Date: Thu, 11 Oct 2007 09:13:07 -0700
>
>>
>>I set up one of my other classes to test this out Steven. I created the
>>update query in the datatable using the designer, added the update method
>to
>>the business class, created a new web page, added a GridView and an
object
>>data source set to my business class, put a break point on the line that
>>should do the actual update, ran it in debug mode, clicked Edit, changed
a
>>value and then clicked update and the code executed as expected and broke
>on
>>the line that should do the updating. When the code was stopped at that
>>line, I clicked the stop debugging button on the tool bar and the
database
>>was indeed updated to the new value I set. While the code was stopped on
>the
>>update line, I checked the database and the values had not been changed
at
>>that point. So, this is happening after the stop debugging button has
been
>>clicked in the VS 2005 user interface.
>>Here's the code for my business class that I used for test. I do not
>believe
>>it's anything in the business class that's causing this. I think it's a
>bug
>>in VS 2005???
>>
>>Imports Microsoft.VisualBasic
>>Imports System.Data.SqlClient
>>Imports System.Data
>>Imports CatsDsTableAdapters
>>
>> _
>>Public Class PropertyTypesBLL
>> Private ptTA As CntyPropertyTypesTableAdapter
>>
>> Protected ReadOnly Property Adapter() As CntyPropertyTypesTableAdapter
>> Get
>> If ptTA Is Nothing Then
>> ptTA = New CntyPropertyTypesTableAdapter
>> End If
>> Return ptTA
>> End Get
>> End Property
>>
>>
>
O
>bjectMethodType.Select,
>>True)> _
>> Public Function GetPropertyTypes() As CatsDs.CntyPropertyTypesDataTable
>> Return Adapter.GetPropertyTypes
>> End Function
>>
>>
>
O
>bjectMethodType.Select,
>>False)> _
>> Public Function GetPropertyTypeByPropertyTypeId(ByVal propertyTypeId
As
>>Integer) As CatsDs.CntyPropertyTypesDataTable
>> Return Adapter.GetPropertyTypeByPropertyTypeId(propertyTypeId)
>> End Function
>>
>>
>
O
>bjectMethodType.Update,
>>True)> _
>> Public Function UpdateCntyPropertyType(ByVal propertyType As String,
>>ByVal propertyTypeId As Integer) As Boolean
>> Return Adapter.UpdateCntyPropertyType(propertyType, propertyTypeId)
>> End Function
>>End Class
>>
>>
>>Steve
>>"Steven Cheng[MSFT]" wrote in message
>>news:mp7Ogj%23CIHA.360@TK2MSFTNGHUB02.phx.gbl...
>>> Hi SA,
>>>
>>> I think this is certainly not the expected behavior. I'm wondering
>whether
>>> there is some component specifcy or project specific things that result
>to
>>> this problem. Would you try use a very simpler DataAccess class to test
>>> the behavior or your can create a different project for test also.
>>>
>>> Sincerely,
>>>
>>> Steven Cheng
>>>
>>> Microsoft MSDN Online Support Lead
>>>
>>>
>>> This posting is provided "AS IS" with no warranties, and confers no
>>> rights.
>>> --------------------
>>>>From: "SAL"
>>>>Subject: Data Layer, Business logic layer help
>>>>Date: Wed, 10 Oct 2007 14:36:18 -0700
>>>
>>>>
>>>>Hello,
>>>>I have a Dataset that I have table adapters in I designed using the
>>> designer
>>>>(DataLayer). I have a business logic layer that immulates the DataLayer
>>>>which may/may not have additional logic in. My business classes are, of
>>>>course, decorated with the:
>>>>
>>>> attribute.
>>>>
>>>>So, I drop a GridView on a webform and set its datasource to an
>>>>ObjectDatasource which in turn is using one of my business logic
classes.
>>>>
>>>>I'm noticing something I find odd in one of my Gridviews. I have it's
>>>>datasource set as an object data source which is using a business logic
>>>>class. I set the update method to an update method in my business logic
>>>>class and the code does indeed step into this update function when
after
>I
>>>>have clicked the Edit button, edit data and then click the Update button
>>> on
>>>>the GridView. So, there the line in this Update function that looks like
>>>>this:
>>>>
>>>>Return Adapter.UpdateCntyAssetsAssetManagement(ant, nlca, ar, an,
>>>>cntyAssetsId)
>>>>
>>>>What I find odd is if I stop debugging before the above line, the data
in
>>>>the database still gets changed.
>>>>Can anyone tell me why this might occur?
>>>>If this is S.O.P. (standard operating proceedure), what could possibly
be
>>>>the purpose of creating a business logic layer to begin with?
>>>>
>>>>Thoughts?
>>>>I have a couple of other issues with this GridView as well but thought I
>>>>should get this one ironed out first.
>>>>Thanks
>>>>
>>>>SAL
>>>>
>>>>
>>>>
>>>
>>
>>
>>
>
>
Re: Data Layer, Business logic layer help
am 22.10.2007 11:53:12 von stcheng
Hi SAL,
After some further research, I did found an existing record indicate this
problem. Actually, this is the behavior of .NET managed debugging. Here is
the detailed description of the issue:
*** Problem Description *******************************************
Behavior
There are cases, when program execution continues after 'Stop debugging'
option
(menu or toolbar) selected in Visual Studio .NET.
Steps to reproduce behavior
1. Create default ASP.NET VB application
2. Add WebForm
3. Add Button to WebForm
4. Add following code to WebForm (you will, probably, have to update
connection
string):
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs)
Handles Button1.Click
Dim cn As New SqlClient.SqlConnection("server=.;uid=sa;pwd=;initial
catalog=Northwind;")
cn.Open()
Dim cmd As New SqlClient.SqlCommand("update categories set
categoryname=categoryname+'1' where categoryid=1", cn)
cmd.ExecuteNonQuery()
End Sub
5. Set breakpoint on first line of Button1_Click and run the program.
6. Hit 'Stop Debugging' button immediately after debugger reach breakpoint.
7. Inspect your database. In most cases it will be updated!
************************************************
So far you can consider the following resolution:
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Cause
Turns out that VS.NET debugger does not suppose to halt managed process
execution
when you 'Stop Debugging'. It is just detaches from process. With unmanaged
code,
this requires killing process.
Resolution
If you will check "Unmanaged code debugging' option in
Project>Properties>Configuration Properties>Debugging, execution will stop
immediately, when 'Stop Debugging' selected.
This article was found at the following link
http://dotnetjunkies.com/WebLog/leon/archive/2004/08/10/2159 0.aspx
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
Hope this helps.
Sincerely,
Steven Cheng
Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
>Date: Thu, 18 Oct 2007 08:59:35 GMT
>Subject: Re: Data Layer, Business logic layer help
>
>Hi SAL,
>
>After some testing, I've repro this problem and got the same behavior as
>you mentioned. Currently I'll do some further research on this and will
let
>you know if I get any new update.
>
>Sincerely,
>
>Steven Cheng
>
>Microsoft MSDN Online Support Lead
>
>
>This posting is provided "AS IS" with no warranties, and confers no rights.
>
>
Re: Data Layer, Business logic layer help
am 24.10.2007 12:00:10 von stcheng
Hi SAL,
Any progress on this or does the information in my last reply help some?
Please feel free to let me know if there is anything else need help.
Sincerely,
Steven Cheng
Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no rights.
Re: Data Layer, Business logic layer help
am 11.01.2008 20:11:44 von Sal
Steven,
I haven't looked at this for some time, obviously. The information you
provided concerning the "Unmanaged code debugging" is good to know. What
I've been doing in the mean time is dragging the cursor (yellow in VB) over
the lines of code I didn't want to execute. I think that works but I can't
swear to it yet. I will try your solution as well. I hope there are no side
effects though...
SAL
"Steven Cheng[MSFT]" wrote in message
news:HYqO2SiFIHA.5176@TK2MSFTNGHUB02.phx.gbl...
> Hi SAL,
>
> Any progress on this or does the information in my last reply help some?
>
> Please feel free to let me know if there is anything else need help.
>
> Sincerely,
>
> Steven Cheng
>
> Microsoft MSDN Online Support Lead
>
>
> This posting is provided "AS IS" with no warranties, and confers no
> rights.
>
Re: Data Layer, Business logic layer help
am 14.01.2008 03:24:53 von stcheng
Hi SAL,
Glad to hear from you. Sure, welcome to post here if you got any further
results.
Sincerely,
Steven Cheng
Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
>From: "SAL"
>Subject: Re: Data Layer, Business logic layer help
>Date: Fri, 11 Jan 2008 11:11:44 -0800
>
>Steven,
>I haven't looked at this for some time, obviously. The information you
>provided concerning the "Unmanaged code debugging" is good to know. What
>I've been doing in the mean time is dragging the cursor (yellow in VB)
over
>the lines of code I didn't want to execute. I think that works but I can't
>swear to it yet. I will try your solution as well. I hope there are no
side
>effects though...
>
>SAL
>
>