跪求C# .net 修改密码的代码
页面设计如图,数据库为Access数据库,表名为Login,字段为LID,UID,LPASS;其中UID为账号,LPASS为密码,LID为编号...
页面设计如图,数据库为Access数据库,表名为 Login,字段为LID,UID,LPASS;其中UID为账号,LPASS为密码,LID为编号
展开
2个回答
展开全部
先检查旧密码对不对。
SELECT * FROM Login WHERE UID=XX AND LPASS=旧密码
如果没查到数据。提示旧密码不对
如果查到一条
UPDATE Login SET LPASS = 新密码 WHERE UID = XXX;
具体链接数据的方法
/// <summary>
/// 执行SQL
/// </summary>
/// <param name="SQL">SQL 语句</param>
/// <returns></returns>
public static ICollection Select(string SQL)
{
try
{
OleDbConnection _connection = null;
string strConnection = "Provider=Microsoft.Jet.OleDb.4.0;";
strConnection += @"Data Source=C:\Users\XX\Desktop\第一次\App_Data\area.mdb";
_connection = new OleDbConnection(strConnection);
_connection.Open();
OleDbCommand acommand = new OleDbCommand(SQL, _connection);
OleDbDataAdapter Da = new OleDbDataAdapter(acommand);
DataSet ds = new DataSet();
Da.Fill(ds,"select");
DataView dv = ds.Tables["select"].DefaultView;
_connection.Close();
_connection.Dispose();
Da.Dispose();
return dv;
}
catch (System.Exception ex)
{
return null;
}
}
SELECT * FROM Login WHERE UID=XX AND LPASS=旧密码
如果没查到数据。提示旧密码不对
如果查到一条
UPDATE Login SET LPASS = 新密码 WHERE UID = XXX;
具体链接数据的方法
/// <summary>
/// 执行SQL
/// </summary>
/// <param name="SQL">SQL 语句</param>
/// <returns></returns>
public static ICollection Select(string SQL)
{
try
{
OleDbConnection _connection = null;
string strConnection = "Provider=Microsoft.Jet.OleDb.4.0;";
strConnection += @"Data Source=C:\Users\XX\Desktop\第一次\App_Data\area.mdb";
_connection = new OleDbConnection(strConnection);
_connection.Open();
OleDbCommand acommand = new OleDbCommand(SQL, _connection);
OleDbDataAdapter Da = new OleDbDataAdapter(acommand);
DataSet ds = new DataSet();
Da.Fill(ds,"select");
DataView dv = ds.Tables["select"].DefaultView;
_connection.Close();
_connection.Dispose();
Da.Dispose();
return dv;
}
catch (System.Exception ex)
{
return null;
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询