本帖最后由 呵呵哒 于 2014-12-18 10:14 编辑
直接调试出现的问题
逐步调试出现的问题
这行代码,我同学用的没问题,我自己做就运行错误咯using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.OleDb;
public partial class change_password : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button2_Click(object sender, EventArgs e)
{
Response.Redirect("login-movie.aspx");
}
protected void Button1_Click(object sender, EventArgs e)
{
string str = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Server.MapPath("cinema.mdb");
OleDbConnection con = new OleDbConnection(str);
con.Open();
OleDbCommand comm = new OleDbCommand("select * from yonghu where Id = '" + TextBox1.Text + " '", con);
OleDbDataReader c = comm.ExecuteReader();
if (!c.Read())
{
Label5.Visible = true;
Label5.Text = "没有此用户!";
c.Close();
return;
}
OleDbCommand com = new OleDbCommand("select Password from yonghu where Id = '" + TextBox1.Text + " '", con);
String ha = com.ExecuteScalar().ToString();
if (TextBox2.Text != ha)
{
//Label6.Visible = true;
Label5.Text = "用户名与初始密码不相符!";
}
if (TextBox2.Text == ha)
{
//Label6.Visible = false;
OleDbCommand comn = new OleDbCommand("update yonghu set Password = '" + TextBox4.Text + "' where Id = '" + TextBox1.Text + " '", con);
comn.CommandText = "update yonghu set Password = '" + TextBox4.Text + "' where Id = '" + TextBox1.Text + " '";
comn.Connection = con;
comn.ExecuteNonQuery();
con.Close();
Label7.Visible = true;
}
}
}
一旦运行就会出错,如图所示 |