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();