Click here to Skip to main content
15,893,904 members
Home / Discussions / C#
   

C#

 
GeneralRe: Transferring focus from a textbox to a button Pin
Som Shekhar24-Jan-10 3:18
Som Shekhar24-Jan-10 3:18 
GeneralRe: Transferring focus from a textbox to a button [Modified] Pin
Rod Kemp24-Jan-10 3:34
Rod Kemp24-Jan-10 3:34 
AnswerRe: Transferring focus from a textbox to a button Pin
Jimmanuel24-Jan-10 3:16
Jimmanuel24-Jan-10 3:16 
GeneralRe: Transferring focus from a textbox to a button Pin
gamer112724-Jan-10 3:53
gamer112724-Jan-10 3:53 
GeneralRe: Transferring focus from a textbox to a button Pin
Jimmanuel24-Jan-10 4:23
Jimmanuel24-Jan-10 4:23 
GeneralRe: Transferring focus from a textbox to a button Pin
gamer112724-Jan-10 4:34
gamer112724-Jan-10 4:34 
GeneralRe: Transferring focus from a textbox to a button Pin
gamer112724-Jan-10 4:14
gamer112724-Jan-10 4:14 
AnswerRe: Transferring focus from a textbox to a button Pin
gamer112724-Jan-10 4:18
gamer112724-Jan-10 4:18 
Now I have a new problem. Whenever I click the Log-In button it doesn't show an error message even if there's no entered data or the entered username and passwords are both wrong. It just do the event of logging in if both the username and passwords are correct. The username and password are saved in an MS Access database and i used SELECT query to check if both exists. Here is the code to clearly understand:

string sConnection = "Provider = Microsoft.Jet.OLEDB.4.0;" + "Data Source = Schedule.mdb";

            try
            {
                OleDbConnection dbConnect = new OleDbConnection(sConnection);
                dbConnect.Open();

                string sqlString = "SELECT * FROM LogIn WHERE ID = '" + txtBoxLogIn.Text + "' AND Password = '" + txtBoxPassword.Text + "';";

                OleDbCommand dbCmd = new OleDbCommand();
                dbCmd.CommandText = sqlString;
                dbCmd.Connection = dbConnect;

                OleDbDataReader dbReader;
                dbReader = dbCmd.ExecuteReader();

                while (dbReader.Read())
                {
                    if (dbReader[0].ToString() == txtBoxLogIn.Text && dbReader[1].ToString() == txtBoxPassword.Text )
                    {
                        frmMainForm frmMainForm = new frmMainForm();
                        frmMainForm.ShowDialog();
                        this.Close();
                    }
                    else
                    {
                        MessageBox.Show("Either the Username or Password does not exist", "Log-In Error", MessageBoxButtons.OKCancel, MessageBoxIcon.Error);
                    }
                }
                
                dbReader.Close();
                dbConnect.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
                return;
            }


Did I do something wrong?
GeneralRe: Transferring focus from a textbox to a button Pin
Jimmanuel24-Jan-10 4:38
Jimmanuel24-Jan-10 4:38 
GeneralRe: Transferring focus from a textbox to a button Pin
gamer112724-Jan-10 5:18
gamer112724-Jan-10 5:18 
GeneralRe: Transferring focus from a textbox to a button Pin
Jimmanuel24-Jan-10 5:32
Jimmanuel24-Jan-10 5:32 
GeneralRe: Transferring focus from a textbox to a button Pin
gamer112724-Jan-10 5:53
gamer112724-Jan-10 5:53 
GeneralRe: Transferring focus from a textbox to a button Pin
Jimmanuel24-Jan-10 5:58
Jimmanuel24-Jan-10 5:58 
GeneralRe: Transferring focus from a textbox to a button Pin
ragnaroknrol25-Jan-10 2:36
ragnaroknrol25-Jan-10 2:36 
QuestionMy Options Window Pin
Jassim Rahma24-Jan-10 1:50
Jassim Rahma24-Jan-10 1:50 
AnswerRe: My Options Window Pin
Som Shekhar24-Jan-10 2:22
Som Shekhar24-Jan-10 2:22 
QuestionPassing and displaying variables in forms Pin
Wogboiii23-Jan-10 23:36
Wogboiii23-Jan-10 23:36 
AnswerRe: Passing and displaying variables in forms Pin
Som Shekhar23-Jan-10 23:51
Som Shekhar23-Jan-10 23:51 
GeneralRe: Passing and displaying variables in forms Pin
Wogboiii24-Jan-10 0:01
Wogboiii24-Jan-10 0:01 
GeneralRe: Passing and displaying variables in forms Pin
Som Shekhar24-Jan-10 0:05
Som Shekhar24-Jan-10 0:05 
GeneralRe: Passing and displaying variables in forms Pin
Wogboiii24-Jan-10 0:09
Wogboiii24-Jan-10 0:09 
GeneralRe: Passing and displaying variables in forms Pin
Som Shekhar24-Jan-10 0:14
Som Shekhar24-Jan-10 0:14 
GeneralRe: Passing and displaying variables in forms Pin
Wogboiii24-Jan-10 17:21
Wogboiii24-Jan-10 17:21 
GeneralRe: Passing and displaying variables in forms Pin
Som Shekhar24-Jan-10 17:47
Som Shekhar24-Jan-10 17:47 
AnswerRe: Passing and displaying variables in forms Pin
sanforjackass24-Jan-10 0:15
sanforjackass24-Jan-10 0:15 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.