C#中Access的问题
string pws = this.textBox1.Text.Trim();string myConStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=LXL.mdb;";
OleDbConnection myCon = new OleDbConnection(myConStr);
myCon.Open();
string mm = "Select 密码 From mima where 密码='" + pws + "'";
这是开始的语句,请各位帮我写一下后面的,我弄不出来啊.谢谢了!
我现在就是不知道返回对比结果的语句,请各位帮我写哈啊!C#语句! --------------------编程问答-------------------- string pws = this.textBox1.Text.Trim();
string username = ""; //获取用户名
string myConStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=LXL.mdb;";
OleDbConnection myCon = new OleDbConnection(myConStr);
myCon.Open();
string mm = "Select 密码 From mima where username='" + username + "'";
if (mm == pwd)
{
//登录
}
else
{
//用户名和密码错误
}
--------------------编程问答--------------------
--------------------编程问答-------------------- 不小心多写了个Db.
OleDbCommand command = new OleDbCommand(mm, myCon);
object obj = command.ExecuteScalar();
if (obj == Db.DBNull.Value)
{
//密码错误
}
OleDbCommand command = new OleDbCommand(mm, myCon);
object obj = command.ExecuteScalar();
if (obj == DBNull.Value)
{
//密码错误
}
--------------------编程问答-------------------- OleDbCommand command = new OleDbCommand(mm,myCon);
OleDbDataReader reader = command.ExecuteDataReader();
string sPwd = String.Empty
try
{
if (reader != null && reader.read()
{
sPwd = reader.GetString(0);
}
if (sPwd.Trim == pws)
{
// login
myCon.Close();
}
else
{
//error handling.
}
}
catch()
{
myCon.Close();
}
can use Dataset and so on.
补充:.NET技术 , C#