关于登录界面的几个问题
小弟是刚学习C#的初学者,在做一个登陆界面的时候出现了几个问题,希望高手们帮忙解决下,小弟现在这里谢过了出现的问题:
程序代码:using System;
using System.Collections.Generic;
using using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.Odbc;
using System.Data.SqlClient;
namespace Login
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void label1_Click(object sender, EventArgs e)
{
}
private void label2_Click(object sender, EventArgs e)
{
}
private void button1_Click_1(object sender, EventArgs e)
{
if (textBox1.Text == "" || textBox2.Text == "")
{
MessageBox.Show(" 用户名或密码不能为空!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else
{
string strConnection = "user id = sa;password =admin;";
strConnection += "Database = Project ;Server = ZLJUN\\GSQL;";
SqlConnection objConnection = new SqlConnection(strConnection);
string sqlStr = "select * from login where login_name = '" + textBox1.Text
+ "' and login_password = '" + textBox2.Text + "'";
SqlConnection objConnection = new SqlConnectio(sqlStr, objConnection);
DataTable dt = new DataTable();
objConnection.Fill(dt);
int i = dt.Rows.Count;
if (i >= 1)
{
MessageBox.Show("用户名和密码都正确,可以成功登录!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
}
private void button2_Click(object sender, EventArgs e)
{
textBox1.Text = "";
textBox2.Text = "";
}
private void button3_Click(object sender, EventArgs e)
{
this.Close();
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
}
private void Form1_Load(object sender, EventArgs e)
{
}
}
}
出现的问题:








