求C# windows程序 用户名 密码 验证代码

来源:百度知道 编辑:UC知道 时间:2024/05/17 21:00:57
初学者请求帮助,求各位高手照顾菜鸟,给出详细的代码,最好有连接数据库--读出数据--对比输入--错误退出--提示等,万分感谢中!!!!

我写的是vs.net2003的代码:
namespace 密码验证
{
public class mimayanzheng : System.Windows.Forms.Form
{
private DataTable myTable;
private DataRow myRow;
}
private void button1_Click(object sender, System.EventArgs e)
{
SqlConnection con=new SqlConnection("server=.;database=data;uid=sa;pwd=");
con.Open();
SqlDataAdapter sda=new SqlDataAdapter("select * from 用户信息表",con);
sda.Fill(this.myTable);
for(int i=0;i<myTable.Rows.Count;i++)
{
this.myRow=this.myTable.Rows[i];
if(this.myRow[0].ToString().Trim()==this.textBox1.Text.ToString().Trim()&&this.myRow[1].ToString().Trim()==this.textBox2.Text.ToString().Trim())
{
MessageBox.Show("密码正确");
}
else
MessageBox.Show("不正确");
}
}
}

sqlconnection con=new sqlconnection("