I wrote a code for a user to enter in their username and authorization, database and datasets and some other information all to be verified within the code. The code works fine but the problem I am having is basic formatting making it run cleaner and checking for all user errors.

I wanted to know how to make it so the user must enter in certain things first before they move on. Right now it lets them enter their username and password correctly but they must alot enter in dataset information to be able to move on, and they really just need to login before not the other stuff...If someone could help me with setting user input I guess that would be great.

**I am using C# code behind in asp.net by the way**

I am including some code below to show you the login code but it realy doesn't relate...
Thanks!

SqlCommand cmd;
            string cmdString = "SELECT [userID] FROM [user_verification] WHERE" + "(([userID] = @username) AND ([auth_lvl] = @authlvl))";
            cmd = new SqlCommand(cmdString, con);
            cmd.Parameters.Add("@username", SqlDbType.VarChar, 50);
            cmd.Parameters["@username"].Value = username.Text;
            cmd.Parameters.Add("@authlvl", SqlDbType.VarChar, 50);
            cmd.Parameters["@authlvl"].Value = authlvl.Text;

            //read information in database
            SqlDataReader myReader;
            myReader = cmd.ExecuteReader(CommandBehavior.CloseConnection);
            if (myReader.Read())
            {
                Response.Write("Correct Login!");
            }
            else
            {
                Response.Write("Invalid Credentials");
            }
            myReader.Close();
            con.Close();

I don't really understand the question but if there are fields you need the user to complete use required field validators to make sure they are filled out. You can also use range validators and regular expression validators to check for the format of the input.

Is that what you need?

I don't really understand the question but if there are fields you need the user to complete use required field validators to make sure they are filled out. You can also use range validators and regular expression validators to check for the format of the input.

Is that what you need?

Yes, and right now it won't let me enter in the username and password without entering the dataset and database. I wanted to format it so I can check the username and password before I enter in everything else.

So at the moment it is requiring you to enter all four pieces of information? Are you using validators? Because they will get in the way if you want to only work with some inputs. MAybe you could post up your code so we can get a look at what is going on?

user required field validator for validating your input values in asp.net

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.