求帮助!
asp吧
全部回复
仅看楼主
level 1
这行代码,我同学用的没问题,我自己做就运行错误咯
2014年12月17日 12点12分 1
level 1
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;
}
}
}
2014年12月17日 12点12分 2
level 1
代码的目的是为了修改yonghu表中的数据[委屈]
2014年12月17日 12点12分 3
level 1
一旦运行就出现
2014年12月17日 12点12分 4
level 1
逐语句调试出现的提示是这样的
2014年12月17日 13点12分 5
level 9
去.net吧
2014年12月17日 13点12分 6
1