示例#1
0
 /// <summary>
 /// Checks if username and password are valid and then logs to the shop.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btnLogin_Click(object sender, EventArgs e)
 {
     using (SqlConnection sqlCon = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Users\Marius\source\repos\ProiectIP\DataBase\LoginDB.mdf;Integrated Security=True;Connect Timeout=30"))
     {
         string         query = "Select * from [Table] where Username = '******' COLLATE SQL_Latin1_General_CP1_CS_AS and Password= '******' COLLATE SQL_Latin1_General_CP1_CS_AS";
         SqlDataAdapter sdata = new SqlDataAdapter(query, sqlCon);
         DataTable      dtbl  = new DataTable();
         sdata.Fill(dtbl);
         if (dtbl.Rows.Count == 1)
         {
             MainForm objMain = new MainForm();
             this.Hide();
             objMain.Show();
             DisplayEmail();
             DisplayName();
             DisplayAdress();
         }
         else
         {
             MessageBox.Show("Invalid username and/or password!");
         }
     }
 }