Data Layer, Business logic layer help

S

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:

<System.ComponentModel.DataObject()> 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
 
O

olrbengax

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:

<System.ComponentModel.DataObject()> 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
 
S

Steven Cheng[MSFT]

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.
--------------------
 
S

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

<System.ComponentModel.DataObject()> _
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

<System.ComponentModel.DataObjectMethodAttribute(System.ComponentModel.DataObjectMethodType.Select,
True)> _
Public Function GetPropertyTypes() As CatsDs.CntyPropertyTypesDataTable
Return Adapter.GetPropertyTypes
End Function

<System.ComponentModel.DataObjectMethodAttribute(System.ComponentModel.DataObjectMethodType.Select,
False)> _
Public Function GetPropertyTypeByPropertyTypeId(ByVal propertyTypeId As
Integer) As CatsDs.CntyPropertyTypesDataTable
Return Adapter.GetPropertyTypeByPropertyTypeId(propertyTypeId)
End Function

<System.ComponentModel.DataObjectMethodAttribute(System.ComponentModel.DataObjectMethodType.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
 
S

Steven Cheng[MSFT]

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.
--------------------
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

<System.ComponentModel.DataObject()> _
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
<System.ComponentModel.DataObjectMethodAttribute(System.ComponentModel.DataO
bjectMethodType.Select,
True)> _
Public Function GetPropertyTypes() As CatsDs.CntyPropertyTypesDataTable
Return Adapter.GetPropertyTypes
End Function
<System.ComponentModel.DataObjectMethodAttribute(System.ComponentModel.DataO
bjectMethodType.Select,
False)> _
Public Function GetPropertyTypeByPropertyTypeId(ByVal propertyTypeId As
Integer) As CatsDs.CntyPropertyTypesDataTable
Return Adapter.GetPropertyTypeByPropertyTypeId(propertyTypeId)
End Function
<System.ComponentModel.DataObjectMethodAttribute(System.ComponentModel.DataO
bjectMethodType.Update,
 
S

Steven Cheng[MSFT]

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: (e-mail address removed) (Steven Cheng[MSFT])
Organization: Microsoft
Date: Tue, 16 Oct 2007 02:48:48 GMT
Subject: Re: Data Layer, Business logic layer help
 
S

Steven Cheng[MSFT]

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/21590.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.


--------------------
 
S

Steven Cheng[MSFT]

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.
 
S

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
 
S

Steven Cheng[MSFT]

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.

--------------------
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,014
Latest member
BiancaFix3

Latest Threads

Top