This is a migrated thread and some comments may be shown as answers.

How to avoid duplicate userid in silverlight

0 Answers 43 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Vikram
Top achievements
Rank 1
Vikram asked on 18 Sep 2012, 06:53 AM
I am beginner and developing a silverlight navigation application with SQL Server 2008.
 
I have a 'Registration' table where initially users request for membership are stored. The admins will verify them and later the particular user details are moved to 'Members' table from 'Registration'. Moreover when the term/period of membership comes to end the same details are finally moved to 'PastMembers' table from 'Members' table.
 
Now what I wanted is that before the registration details are submitted it should be checked in all three tables(Registration,Members,PastMembers) for username specified and if any record is found it should restrict user by submitting details to avoid duplicate userids.
 

I searched and tried to count the rows but even though I have a record with same userid I get count=0
 
Please let me know if any other better option or any rectification in this logic (please be a more brief since I am a beginner)
 

Checking in just first table
 
Code in submit button click handler

myDomainContext objctx1 = new myDomainContext();
var query1 = objctx1.GetregistrationsByIDQuery(userid_txtbx.Text);
objctx1.Load(query1);
var count = (from c in objctx1.registrations where c.userid == userid_txtbx.Text select c).Count();
// To see how many rows there
MessageBox.Show(count.ToString());
// Code for restricting details to be submitted


Function in myDomainService.cs

// Query to get usernames from registrations table
public IQueryable<registration> GetregistrationsByID(string id)
{
   return this.ObjectContext.registrations.Where(s => s.userid == id);
}


consider sample fields in tables as:
 
Tables: Registration,Members,PastMembers having
 
userid,
fullname,
contact
Tags
General Discussions
Asked by
Vikram
Top achievements
Rank 1
Share this question
or