回覆列表
  • 1 # 滴逃逃

    例子:

    namespace login

    {

    public partial class loginForm : Form

    {

    public loginForm()

    {

    InitializeComponent();

    }

    private void button1_Click(object sender, EventArgs e)

    {

    SqlConnection conn = null;

    try

    {

    string connstring = "data source=.;initial catalog =MyQQ;integrated security=true";

    conn = new SqlConnection(connstring);

    conn.open();

    string selectstring = "select Count(MyQQID) from MyQQInfo where MyQQID= " + txtID.Text.Trim() + "and Password=" + txtPSW.Text.Trim();

    cmd.Connection = conn;

    SqlCommand cmd = new SqlCommand(selectstring,conn);

    int i = int.Parse(cmd.ExecuteScalar().ToString());

    if(i == 1)

    {

    MessageBox.Show("登入成功");

    Insert i = new Insert();

    i.Show();

    }

    else

    {

    MessageBox.Show("登入失敗");

    }

    }

    catch (SqlException ex)

    {

    throw ex;

    }

    finally

    {

    conn.close();

    }

    }

    }

  • 中秋節和大豐收的關聯?
  • 鐵板燒技術在哪裡學?