Today's Posts Follow Us On Twitter! TFL Members on Twitter  
Forum search: Advanced Search  
Navigation
Marketplace
  Members Login:
Lost password?
  Forum Statistics:
Forum Members: 24,254
Total Threads: 80,792
Total Posts: 566,471
There are 1464 users currently browsing (tf).
 
  Our Partners:
 
  TalkFreelance     Design and Development     Programming     .NET and MSSQL :

[ASP.NET\VB] User exists

Thread title: [ASP.NET\VB] User exists
Closed Thread    
    Thread tools Search this thread Display Modes  
12-21-2007, 12:04 AM
#1
Bursh. is offline Bursh.
Status: Member
Join date: Nov 2006
Location: In your bath.
Expertise:
Software:
 
Posts: 121
iTrader: 0 / 0%
 

Bursh. is on a distinguished road

Send a message via AIM to Bursh. Send a message via MSN to Bursh.

  Old  [ASP.NET\VB] User exists

OK. So i'm dealing with the ASP.NET membership systems right now and i'm writing a page for activating a user based on the code and the username supplied in the querystring.

What I need to do is check to see if the username supplied exists in the users table.

There only way I can think to do this, is get a collection of all the users in the database, and see if it's in the collection. 2 problems with that though:
  1. I don't know how to do that (yet)
  2. It will be really slow when the database gets bigger
Is there any other way to do it? And could somebody show me how to check if something is(or in this case isn't) in a collection using an if statement (I want to do "If value isn't in collection, do error page")?

01-01-2008, 12:52 AM
#2
phpintheusa is offline phpintheusa
phpintheusa's Avatar
Status: I'm new around here
Join date: Dec 2007
Location: Tennessee
Expertise:
Software:
 
Posts: 20
iTrader: 0 / 0%
 

phpintheusa is on a distinguished road

Send a message via MSN to phpintheusa

  Old

Just try a query like:

'SELECT COUNT(*) FROM `table` WHERE `username`="' . $username . '";

and then jsut use a loop based on the count being greater than vs equal to zero.

01-01-2008, 08:43 PM
#3
Bursh. is offline Bursh.
Status: Member
Join date: Nov 2006
Location: In your bath.
Expertise:
Software:
 
Posts: 121
iTrader: 0 / 0%
 

Bursh. is on a distinguished road

Send a message via AIM to Bursh. Send a message via MSN to Bursh.

  Old

I'm not really sure how to do that. Could you provide a code example please?

01-12-2008, 11:10 PM
#4
Rogem is offline Rogem
Status: Junior Member
Join date: Jan 2008
Location: UK
Expertise:
Software:
 
Posts: 27
iTrader: 0 / 0%
 

Rogem is on a distinguished road

  Old

Originally Posted by phpintheusa View Post
Just try a query like:

'SELECT COUNT(*) FROM `table` WHERE `username`="' . $username . '";
Thats the SQL, I would assume it would be loop(){} or something.

01-23-2008, 12:17 PM
#5
echoSwe is offline echoSwe
Status: Member
Join date: Jul 2005
Location:
Expertise:
Software:
 
Posts: 185
iTrader: 0 / 0%
 

echoSwe is on a distinguished road

  Old

You should not go by their statements as it (1) requires you to use native SQL in your programming code. (2) Leaves you open for SQL injection, (3) Doesn't take into account the .net infrastructure for Authentication. I can go on with more, but I think this is sufficient. Easiest, depending on what you already got is:
Code:
MembershipUser user = Membership.FindUserByUsername("myUser");
if (user != null)
// go ahead and add
else
    txtMsg.Text = "Sorry, username already in use"; //...
Btw... phpintheusa: this isn't php...

Closed Thread    


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

  Posting Rules  
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump:
 
  Contains New Posts Forum Contains New Posts   Contains No New Posts Forum Contains No New Posts   A Closed Forum Forum is Closed