1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- 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.SqlClient;
- namespace konkurs
- {
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- }
- private void button3_Click(object sender, EventArgs e)
- {
- }
- public string constring = "Data Source=DESKTOP-Q8BTJMH;Initial Catalog=konkurs;Integrated Security=True";
- private void button2_Click(object sender, EventArgs e)
- {
- SqlConnection con = new SqlConnection(constring);
- SqlDataReader sqlReader = null;
- con.Open();
- SqlCommand command = new SqlCommand("Select * FROM [dbo].[Users] WHERE login = @login AND password = @password", con);
- command.Parameters.Add("@login", textBox1.Text);
- command.Parameters.Add("@password", textBox2.Text);
- try
- {
- sqlReader = command.ExecuteReader();
- while (sqlReader.Read())
- {
- Form2 fr2 = new Form2();
- fr2.Show();
- }
- }
- catch (Exception ex)
- {
- MessageBox.Show(ex.Message.ToString(), ex.Source.ToString(), MessageBoxButtons.OK, MessageBoxIcon.Error);
- }
- finally
- {
- if (sqlReader != null)
- sqlReader.Close();
- }
- }
-
-
- }
- }
|