Added: 1 year ago
From: Shmv90
Views: 15,638
Sort by time | Sort by thread (beta)

Link to this comment:

Share to:

All Comments (36)

Sign In or Sign Up now to post a comment!
  • Thanks a lottt!! ...=)

  • in the line

    string cmdstr="select count(*) from Registration where UserName" * TextBoxUN.Text *;

    what operator have u used before and after TextBoxUN, its not at all visible please can u re write this line for me in ur replyto this message!! ...

  • @sanasz91 It's like this:

    string cmdstr = "Select count(*) from Registration where UserName" + TextBoxUN.Text + "'";

    Note that before semicolon at last there is single quote between two double quote....like " ' "

  • thanks you very very much ^^

  • ei ...is it applicable for visusal studio 2008?cause when i type the codes that u are typing i get an error codes PLS REPLY

  • Thank you so muchhhh!!!!!! Really APPRECIATE!!! <3

  • I suppose you could redirect to a new page just to diply the message and then using a timer redirct again back o the Registration page... aftersay 5 sec..

    Anyone know how to do this??? Thread.Sleep(5000) doesnt seem to work, same problem as Respose.Write....

  • v nice i will give it a try :P

  • Hi Shmv90.... Great tutorial...!

    Was just wondering... When checking for existing UserName my "int temp" get a 0 (zero) for a new unique userName and any number greater than zero (1, 2, 3... consecutivly) for duplicate UserNames... What is the reason for that do you know?

    I just changed mine to "if (temp !=0)"

    When stepping through the code this works fine, however, when running the program the Response.Write("..."); does not show and the program continues to insert the duplicate UserName :-?

  • @brovashift The whole logic behind that check is to ensure unique username to all registered Users. So, you should use if (temp == 1) or if (temp > 0) in your if loop condition and put Response.Write inside that. Because if variable temp has value 1 or larger that means user exist with same username and user should get notify about that.

  • @Shmv90 Ahh yes of course... normally when a duplicate username is entered the user is notified and a new unique username would be entered, which would mean temp is always either 0 or 1 nd no more... but becaue I was entering the same user several times for testing, thats why I WS getting nmber greater than 1... :) Silly me!

    However, when a duplicate username is found the program still continues to insert the data into the database and the Response.Write does not show...?

  • @brovashift I have replaced Response.Write with a Response.Redirect("Registratio­n.aspx"); which stops the incorrect data being entered into the db but I still cannot dispay a message to notify the user of whats happened or why the Registation form has been reset... Which would be very annoying to a user!

    Do you know of a way to notify the user after a Postback? Is it even possible?

    Thanks again, thumbs up!

  • @brovashift then you should use if (temp > 0) because you already have more than 1 same usernames in your database. Just use this in your if loop condition and see if you get your Response.Write message.

  • @Shmv90 Hi, ive set the if to > 0 but its still not working... Could it be because im using a MasterPage...?

  • why you use isPostback property in this case? Do you think you need it?

    just a silly question...

  • @rmas199 Yeah, it's necessary to check that submit button's event code runs if there's postback occures.

  • @Shmv90 thanks for the reply, i only asked because its not a common practice (at least in all examples i´ve seen) but it´s important to verify if the postback event occurs... but when you click the event button, you know that it will be a postback itself... so every click events are Postbacks, right?? i´m confused... :p

  • i have an error after this code:

    SqlConnection con = new SqlConnection(ConfigurationMan­ager.ConnectionStrings["RegCon­nectionString"].ConnectionStri­ng);

    it says that i must declare an object with "new"

    ??ß

  • "NullReferenceException" is not defined ??

  • i have a error in registration page is

    Somthing bad happen

    wich is written in to the catch

    then what to do?

    and how to solve it?

  • int temp = Convert.ToInt32(userExist.Exec­uteScalar().ToString());

    im having error on this line it says: An expression of non-boolean type specified in a context where a condition is expected, near 'ID'. any one ? adv thx :))

  • catch(Exception er)

    The variable 'er' is declared but never used?

  • Hi

    sorry for my english .......

    (cndString, con) and Parameters get the same error message "does not exist in current context" Why? Can you help me? Thanks

    and

  • Hi Guys, I tried to Register but i get the error message from catch(Exeption er)

    any ideas to fix this prob??

    Greetings from KOSOVA!!

    try... catch (Exception er) {  Response.Write("error, please try again!"); }

  • @computingm What is error saying..??

  • mine doesnt work :(

    you used Catch (Exception er);

    mines error

    

  • Thanks for posting this tutorial... its been very helpful. I am however getting an error when i run the register page. I added an exception mge and was returned this... Insert Error:Syntax error in INSERT INTO statement. I am connecting to an Access DB and have changed the sqlcommand/connection to read OleDbConnection. Any ideas?

    my code - string insCmd="INSERT INTO Registration (UserName, Password, EmailAddress, FullName, Country) VALUES (@UserName, @EmailAddress, @FullName, @Country)";

  • @redshirtdecoy Did you try this:

    string insCmd=@"INSERT INTO Registration (UserName, Password, EmailAddress, FullName, Country) VALUES (@UserName, @EmailAddress, @FullName, @Country)";

    And then u also have to set values for that @ variables.

  • yeah, he if(temp ==1) doesn't work

  • the only thing that dont work is the part of it dont tell you that you have a existing usersname... trying to figure that out.. the if(temp ==1) dont work. finding a way to compare it to the username and then the textbox input. maybe i can get it working there, good video man, but please help?

  • Everything works fine to me. People who want to see it better must use browser full screen.

  • Zoooooooooooom men...

  • Comment removed

Loading...
Alert icon
0 / 00Unsaved Playlist Return to active list
    1. Your queue is empty. Add videos to your queue using this button:
      or sign in to load a different list.
    Loading...Loading...Saving...
    • Clear all videos from this list
    • Learn more