using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.OleDb;
namespace dbclient
{
public partial class monfrm : Form
{
OleDbConnection conn = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=ddb.mdb");
string t="";
public monfrm(string t)
{
InitializeComponent();
this.t=t;
}
private void monfrm_Load(object sender, EventArgs e)
{
}
private void button2_Click(object sender, EventArgs e)
{
this.Dispose();
}
private void button1_Click(object sender, EventArgs e)
{
if (textBox2.Text == textBox3.Text)
{
OleDbCommand dc;
int q = 0;
try
{
conn.Open();
dc = new OleDbCommand("select * from denglu where name='" + t + "'", conn);
OleDbDataReader r = dc.ExecuteReader();
if (r.Read())
{
q = r["password"].ToString() == textBox1.Text.ToString() ? 1 : 0;
}
}
finally
{
conn.Close();
}
MessageBox.Show(q.ToString());
try
{
if (q == 1)
{
if (conn.State == ConnectionState.Closed) conn.Open();
string str = "update denglu set password='" + textBox2.Text + "' where name='" + t + "'";
dc = new OleDbCommand(str, conn);
if (dc.ExecuteNonQuery() > 0) 提示出错!
{
MessageBox.Show("Ð޸ijɹ¦£¡");
}
}
else
MessageBox.Show("ÊäÈëÃÜÂë²»ÕýÈ·£¡");
}
finally
{
conn.Close();
}
}
else
MessageBox.Show("Á½´ÎÊäÈë²»Ò»Ö£¡");
}
}
}