我正在C#中创建一个桌面应用程序,我的代码是:
private void btnLogin_Click(object sender, EventArgs e)
{
if (clsFunctions.recordExist("SELECT AtNumConstructorID, TxtConstructorName AS Fullname FROM tblConstructorDetails WHERE txtUserName = '" + txtUserName.Text + "' AND TxtPassword LIKE '" + txtPassword.Text + "' ", "tblConstructorDetails") == true)
{
clsVariables._sTimeLogin = DateTime.Now.ToLongTimeString();//recording the time of login in the CES
long totalRow = 0;
//Set the Data Adapter
OleDbDataAdapter da = new OleDbDataAdapter("select AtNumConstructorID, TxtConstructorName AS Fullname, tblConstructorDetails.txtUserName FROM tblConstructorDetails WHERE txtUserName =" + txtUserName.Text, clsConnections._olbedbCN);
DataSet ds = new DataSet(); // creating a dataset to enter the values in the dataadapter
da.Fill(ds, "tblConstructorDetails");
totalRow = ds.Tables["tblConstructorDetails"].Rows.Count - 1;
clsVariables._sContId = Convert.ToInt32(ds.Tables["tblConstructorDetails"].Rows[0].ItemArray.GetValue(0));
clsVariables._sConstructor = ds.Tables["tblConstructorDetails"].Rows[0].ItemArray.GetValue(1).ToString();
clsVariables._sUserID = ds.Tables["tblConstructorDetails"].Rows[0].ItemArray.GetValue(2).ToString();
clsUserLogs.RecordLogin(clsVariables._sTimeLogin, clsVariables._sContId);
clsApplication._boolAPP_CONNECTED = true;
this.Close();
}
}
注意:clsFunctions:写入所有常用函数的类 recordexist:function,如果记录可用,则返回true。
对于recorderdexist,我提供了一个查询。文本框中的数据不会传输到 查询,我可以知道,为什么会发生...请帮助SOS ......
答案 0 :(得分:0)
如果您想使密码不区分大小写,请使用:
UPPER(TxtPassword) = UPPER('" + txtPassword.Text + "') "
忽略下面没有看到它不是一个webapp
问题必须出在您的aspx页面或您如何引用该页面。请发布aspx。
我的猜测是你没有把事件挂在右边或没有正确声明txtUserName。