This is the sixth day of my participation in Gwen Challenge

demand

Enter the account and password on the page to query data from the database and return it. After the authentication is successful, you can log in to the main page.

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.Threading; using System.Data.SqlClient; using System.Net; namespace WindowsFormsApp2 { public partial class Form1 : Form { public static Form1 pForm1 = null; private SqlConnection master; Private SqlCommand CMD; Private SqlDataAdapter sqlada; // Define the data adapter object private SqlCommandBuilder SQLBuid; // Define CommandBuilder object private DataSet ds; Public Form1() {pForm1 = this; InitializeComponent(); } private void label7_Click(object sender, EventArgs e) { } private void txtCardNum_TextChanged(object sender, EventArgs e) { } private void btnOpenPort_Click(object sender, EventArgs e) { Form2 frm2 = new Form2(); String textzhanghao = zhanghao.Text; String textmima = mima.Text; string zhanghao1; string mima1; string connString = "server=DESKTOP-=\\SQLEXPRESS; database=master; integrated security=SSPI"; string sqlString = "select sno,sname from student where sno='" + textzhanghao + "'and sname='" + textmima + "' "; master = new SqlConnection(connString); master.Open(); SqlCommand SqlCommand = new SqlCommand(sqlString, master); SqlDataReader sqlDataReader = sqlCommand.ExecuteReader(); If (sqlDatareader.hasrows)// If the user name and password are the same, the next interface {frm2.show (); this.Hide(); } else MessageBox.Show(" account password is incorrect "); }}}Copy the code

Jump interface

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;

namespace WindowsFormsApp2
{
    public partial class Form2 : Form
    {
        public Form2()
        {
            InitializeComponent();
        }

        private void label1_Click(object sender, EventArgs e)
        {

        }

        private void Form2_Load(object sender, EventArgs e)
        {

        }
    }
}

Copy the code

Point a

Looking at the

You are the best

This article uses the article synchronization assistant to synchronize