Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP.net 2.0 Users (aspnet_Users table) create constraint problem

Reply
Thread Tools

ASP.net 2.0 Users (aspnet_Users table) create constraint problem

 
 
ibiza
Guest
Posts: n/a
 
      03-09-2006
Hi all,

I am using ASP.NET 2.0 Membership system, which is driving me nuts. I
have my users, which I create correctly. Then I have a table "Models"
which contains models, created by different users. So I obviously need
to create a relationship between the users and the models. I wanted at
first to create a relationship like I'm used to do it, that is to add
an int field to my Model table that would be a reference on the primary
key of my Primary Table. However, as the primary key on the
aspnet_Users table is a uniqueidentifier, I decided to add a field
model_username instead. Then, I tried to create a relationship between
the aspnet_Users.UserName row and Model.model_username, but sql server
won't let me create it, I don't know why.

What is supposed to be the correct way to implement a constraint with
asp.net 2.0 users? I want to disallow the deletion of a user if he has
created a model.

Thank you,
ibiza

 
Reply With Quote
 
 
 
 
Erik Funkenbusch
Guest
Posts: n/a
 
      03-10-2006
On 9 Mar 2006 11:41:46 -0800, ibiza wrote:

> However, as the primary key on the
> aspnet_Users table is a uniqueidentifier, I decided to add a field
> model_username instead.


Why? I assume you mean you added a field model_username to your new table
(not to the asp.net users table), right? If so, did you make sure it's the
same type and size as the aspnet username field (ie nvarchar(256))?

Also, primary keys must be unique, so if you can have mulitple models per
user, you need to have some kind of sequence number or other value in
addition to username to create your primary key.

> Then, I tried to create a relationship between
> the aspnet_Users.UserName row and Model.model_username, but sql server
> won't let me create it, I don't know why.


What is the error you are getting? It seems to work for me.

> What is supposed to be the correct way to implement a constraint with
> asp.net 2.0 users? I want to disallow the deletion of a user if he has
> created a model.


I'd create a uniqueidentifier in your table, and then create a foreign key
constraint on that. This is guaranteed unique, even if another user is
created with the same name.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re-using a simple type definition; with enumeration constraint andwithout enumeration constraint puvit82 XML 4 02-01-2008 03:46 PM
How can i create new users without utilizing the create user wizar prady ASP .Net 2 12-29-2007 10:46 PM
classroom constraint satisfaction problem Steven Bethard Python 3 10-24-2006 12:02 AM
Bandwidth constraint causing IIS/ASP.NET problem Jack Fox ASP .Net 3 09-11-2005 09:46 PM
Problem Writing to a CSV from a JSP behind a Security Constraint Justin Java 1 08-11-2003 03:40 PM



Advertisments