Results 1 to 8 of 8

Thread: [RESOLVED] Help needed on web application login!

Threaded View

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jan 2005
    Posts
    150

    [RESOLVED] Help needed on web application login!

    Hey guys
    I am fairly new so would be grateful if anyone could help me out...

    i am creating a web application using asp.net with vb.net code which connects to an sql database.

    I am trying to configure some code for my login section which basically figures out if a username already exists and then outputs 'username already exists' in a label.

    At present it works for the first row in the database
    i.e if my database consists of

    username <-- this is the colum name
    user
    user1
    user2

    then if I try and register a new username called 'user' then everything works and the label is updated with the 'username already exists' label.
    but if I try to pick a new username of 'user1' or 'user2' then it doesn't work and it creates a duplicate entry into the database.

    I beleive this is because I am not looping through all the usernames although I am not sure how to do this, can someone please submit the modifed code or instruct me on how to do this loop?

    my current code is :-

    strSQL = "SELECT * FROM users"
    objCmd.CommandText = strSQL
    objReader = objCmd.ExecuteReader()
    If objReader.Read() Then
    If objReader.Item("username") = userTextbox.Text Then
    levelTextbox.Text = "username already exists"
    objReader.Close()
    Else
    objReader.Close()
    strSQL1 = "INSERT INTO users VALUES ( '" + username + "' , ***other fields contianed here (not important)***)"
    objCmd.CommandText = strSQL1
    objCmd.ExecuteNonQuery()

    End If
    End If
    Last edited by eakin; Sep 27th, 2005 at 08:36 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width