Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public partial class Form1 : Form
- {
- public string str = @"Data Source=DESKTOP-9I02IE1;Initial Catalog = trabalhoC#;Integrated Security=True;Pooling=False";
- public Form1()
- {
- InitializeComponent();
- }
- private void button2_Click(object sender, EventArgs e)
- {
- MessageBox.Show("Adeus!");
- this.Close();
- }
- private void button1_Click(object sender, EventArgs e)
- {
- SqlConnection sc = new SqlConnection(str);
- SqlDataAdapter sda = new SqlDataAdapter();
- DataSet ds = new DataSet();
- sda.SelectCommand = new SqlCommand("Select username,password from utilizadores where username = '"+textBox1.Text.ToString()+"' and password = '"+textBox2.Text.ToString() + "' ");
- sc.Open();
- sda.Fill(ds);
- if (ds.Tables[0].Rows.Count>0)
- {
- Form2 f = new Form2();
- f.Show();
- }
- else
- {
- MessageBox.Show("utilizador ou password incorrectas");
- }
- sc.Close();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement