473,503 Members | 1,691 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Business layer wrapping user information and transactions?

I have an application with both Windows Forms and ASP.NET front ends and
uses both integrated web security and a security database. The problem I
have is that I need to syncronize these security databases.

The web front end uses ASP membership with the SQL provider, the database is
moved to the SQL Server instead of the SQL Express datafile.

The Windows Forms app uses tables such as "users" within the database.

If I add a user on the website, I need also to add a user to the database
"users" table.

To achieve this I write a business layer component that wraps both the
security data tables and the ASP.NET membership functions. So for instance,
to delete a user...

[DataObjectMethod(DataObjectMethodType.Delete, true)]
static public void Delete(string UserName)
{
// delete user from internal database table "users"
usersTableAdapter UserTableAdapter = new usersTableAdapter();
int rowsAffected = UserTableAdapter.DeleteByName(UserName);

// delete user from ASP.NET membership database
Membership.DeleteUser(UserName, true);
}

The question is how do I get these two functions into a transaction so that
if the deletion for the ASP.NET member fails, the delete on the internal
database table is rolled back?

--
Best regards
Mark
Jan 18 '07 #1
4 1425
One of the golden rules of software development is never, ever to hold the
same data in more than one place. It's a maintenance nightmare.

Is there no way you can get both front ends to use the same data?
Petere

"Mark Baldwin" <sW*****@community.nospamwrote in message
news:uH*************@TK2MSFTNGP06.phx.gbl...
>I have an application with both Windows Forms and ASP.NET front ends and
uses both integrated web security and a security database. The problem I
have is that I need to syncronize these security databases.

The web front end uses ASP membership with the SQL provider, the database
is moved to the SQL Server instead of the SQL Express datafile.

The Windows Forms app uses tables such as "users" within the database.

If I add a user on the website, I need also to add a user to the database
"users" table.

To achieve this I write a business layer component that wraps both the
security data tables and the ASP.NET membership functions. So for
instance, to delete a user...

[DataObjectMethod(DataObjectMethodType.Delete, true)]
static public void Delete(string UserName)
{
// delete user from internal database table "users"
usersTableAdapter UserTableAdapter = new usersTableAdapter();
int rowsAffected = UserTableAdapter.DeleteByName(UserName);

// delete user from ASP.NET membership database
Membership.DeleteUser(UserName, true);
}

The question is how do I get these two functions into a transaction so
that if the deletion for the ASP.NET member fails, the delete on the
internal database table is rolled back?

--
Best regards
Mark

Jan 18 '07 #2


<<What he said>>

I'd strongly recommend (with emphasis on the strongly) not trying to keep
"sync" data.

Using the Provider Model, you can create your ~own
MyCustomMembershipProvider : MembershipProvider

This will allow you to use your custom tables, and such.

There's no reason why you can't use your MyCustomMembershipProvider from a
Winforms.
You'll just lose the "drag and drop" ability that you have in asp.net 2.0.

See
http://www.15seconds.com/issue/050216.htm

"Peter Bradley" <pb******@uwic.ac.ukwrote in message
news:OQ**************@TK2MSFTNGP04.phx.gbl...
One of the golden rules of software development is never, ever to hold the
same data in more than one place. It's a maintenance nightmare.

Is there no way you can get both front ends to use the same data?
Petere

"Mark Baldwin" <sW*****@community.nospamwrote in message
news:uH*************@TK2MSFTNGP06.phx.gbl...
I have an application with both Windows Forms and ASP.NET front ends and
uses both integrated web security and a security database. The problem I
have is that I need to syncronize these security databases.

The web front end uses ASP membership with the SQL provider, the
database
is moved to the SQL Server instead of the SQL Express datafile.

The Windows Forms app uses tables such as "users" within the database.

If I add a user on the website, I need also to add a user to the
database
"users" table.

To achieve this I write a business layer component that wraps both the
security data tables and the ASP.NET membership functions. So for
instance, to delete a user...

[DataObjectMethod(DataObjectMethodType.Delete, true)]
static public void Delete(string UserName)
{
// delete user from internal database table "users"
usersTableAdapter UserTableAdapter = new usersTableAdapter();
int rowsAffected = UserTableAdapter.DeleteByName(UserName);

// delete user from ASP.NET membership database
Membership.DeleteUser(UserName, true);
}

The question is how do I get these two functions into a transaction so
that if the deletion for the ASP.NET member fails, the delete on the
internal database table is rolled back?

--
Best regards
Mark


Jan 18 '07 #3
And see
http://msdn2.microsoft.com/en-us/lib...5e(VS.80).aspx

(read my other post first)
"Peter Bradley" <pb******@uwic.ac.ukwrote in message
news:OQ**************@TK2MSFTNGP04.phx.gbl...
One of the golden rules of software development is never, ever to hold the
same data in more than one place. It's a maintenance nightmare.

Is there no way you can get both front ends to use the same data?
Petere

"Mark Baldwin" <sW*****@community.nospamwrote in message
news:uH*************@TK2MSFTNGP06.phx.gbl...
I have an application with both Windows Forms and ASP.NET front ends and
uses both integrated web security and a security database. The problem I
have is that I need to syncronize these security databases.

The web front end uses ASP membership with the SQL provider, the
database
is moved to the SQL Server instead of the SQL Express datafile.

The Windows Forms app uses tables such as "users" within the database.

If I add a user on the website, I need also to add a user to the
database
"users" table.

To achieve this I write a business layer component that wraps both the
security data tables and the ASP.NET membership functions. So for
instance, to delete a user...

[DataObjectMethod(DataObjectMethodType.Delete, true)]
static public void Delete(string UserName)
{
// delete user from internal database table "users"
usersTableAdapter UserTableAdapter = new usersTableAdapter();
int rowsAffected = UserTableAdapter.DeleteByName(UserName);

// delete user from ASP.NET membership database
Membership.DeleteUser(UserName, true);
}

The question is how do I get these two functions into a transaction so
that if the deletion for the ASP.NET member fails, the delete on the
internal database table is rolled back?

--
Best regards
Mark


Jan 18 '07 #4
Hello Mark,

As Peter and sloan have suggested, you can build a custom provider to do
the work. Or if you want to manage such synchronized database updating, you
can use the ADO.NET's Transaction(for updating in single database). Or if
the tables are in different database, you can consider using classes in
System.Transacdtions namespace to perform multi-database transaction.

In addition, for ASP.NET SQL Membership &Role provider(and its API), you
can feel free to use it in non-asp.net application also(winform or console
application). What you need to do is simply copy those configuration about
ASP.NET membership & role(from your web application's web.config file to
your non-ASP.NET application's app.config file). Here is a blog article
I've ever writen to demonstrate this:

#Manage database of ASP.NET 2.0 Membership & Role services in non-ASP.NET
context
http://blogs.msdn.com/msdnts/archive...mbership-role-
management-out-of-asp-net-context.aspx

Thus, you can let your winform application use the same API and access the
same membershp &role data as the ASP.NET application.

If you have any other specific question, please feel free to post here.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

This posting is provided "AS IS" with no warranties, and confers no rights.

Jan 19 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1351
by: Bob | last post by:
I've got a 3-tiered WinForms application in C# .net. The presentation layer (client exe) contains references to the Business layer (dll), and everything works great on the same machine, but when...
5
2035
by: G. Stewart | last post by:
The word "Business" in the term implies some sort of commercial aspects or connotations. But from what I can see, that is not necesserially the case at all? So what is the reasoning behind the...
4
2053
by: Big Dave | last post by:
Does anyone have suggestions on how to best handle errors in business objects that are part of a business layer? For example: Public Class Person Private _name as string Public Property Name...
16
8998
by: MS newsgroup | last post by:
I don't have clear reasons why we need business logic layer and data logic layer instead of having only data logic layer. Are there any good reasons for that?
8
4118
by: morleyc | last post by:
Hi, until recently i was quite happy to add data sources from mssql database in visual studio and drag the datasets directly onto the form this creating a directly editable form which worked well....
8
1743
by: Charles Law | last post by:
This is a sort of pattern question, but relating to how components are coupled in a three-tier system. I have a presentation layer, business layer and data access layer, the first is the EXE,...
0
2966
by: JTP PR | last post by:
Business Intelligence software company, Yellowfin today announced its successful foray into the Asia Pacific telecommunications sector through its expanding partner network. Two organisations,...
3
7067
by: psycho | last post by:
I am working on an N-tier application using following components: 1. Data Access Layer using DLINQ which consists of Data Context class and Table Mapping classes. 2. Business Logic Layer....
0
7202
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7278
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7328
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7458
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5578
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5013
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4672
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
1
736
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
380
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.