I've been trying to teach myself how to do this for a few days now but can't figure out certain things.
This is what I have currently and I can't, for the life of me, figure out where I'm wrong at. I hope this isn't a lost cause as I'm trying to help my school get out of using paper for certain things and this is my first step.
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- using System.Data.Sql;
- using System.Data.SqlClient;
- namespace CCCLogin
- {
- public partial class Form2 : Form
- {
- public Form2()
- {
- InitializeComponent();
- }
- private void Exit_Click(object sender, EventArgs e)
- {
- this.Close();
- }
- private void Login_Click(object sender, EventArgs e)
- {
- SqlConnection con = new SqlConnection(@"Data Source=(LOCALDB)\MSSQLLocalDB.C:\USERS\MICHAELC0837\DOCUMENTS\CCCLOGIN\CCCEMPLOYEES.mdf; Initial Catalog=CCCEMPLOYEES.mdf; Integrated Security=True");
- SqlDataAdapter sda = new SqlDataAdapter("select count(*) from Username where username='" + UserTxtBox + "and password='" + PassTxtBox + "'", con);
- DataTable dt = new DataTable();
- sda.Fill(dt);
- if (dt.Rows[0][0]).ToString() == "1")
- {
- this.Hide();
- CCCLogin ss = new CCCLogin();
- ss.Show();
- }
- else
- MessageBox.Show("please enter correct username and password", "alert", MessageBoxButtons.OK, MessageBoxIcon.Error);
- }
- }
- }
- }