D
daoba
Unregistered / Unconfirmed
GUEST, unregistred user!
我使用常用函数时老提示错误,比如下段程序中的Trim(),LTrim(),RTrim(),提示不存在。请帮忙分析,我还需要加载哪些命名控件?
程序段开头如下:
<%@Page Language="C#"
Debug="true"
%>
<%@Import NameSpace="System.Data"
%>
<%@Import NameSpace="System.Data.SqlClient"
%>
<script Language="C#"
runat="server">
private void LoginCheck(Object sender, EventArgs E) //验证登录合法性
{
SqlConnection Conn = new SqlConnection(Application["DbConnStr"].ToString());
SqlCommand Comm = new SqlCommand();
SqlDataReader dr;
Comm.Connection = Conn;
Comm.CommandText = "select * from OaUser where LoginName='"
+ OaLoginName.Text + "'";
Comm.Connection.Open();
dr = Comm.ExecuteReader();
tmp.Text = "'"
+ OaLoginPass.Text +"'";
if(dr.Read())
{
tmp.Text = tmp.Text + "'"
+ dr["Password"].RTrim() +"'";
String tmpstr = "1 ";
if(dr["Password"] == tmpstr) //登录成功后处理语句
{
tmpl.Text = "Login success!";
}
else
//密码不正确时处理语句
{
tmpl.Text = "Password wrong!";
}
}
else
//用户名不存在时处理语句
{
tmpl.Text = "user not exist!";
}
dr.Close();
}
</script>
程序段开头如下:
<%@Page Language="C#"
Debug="true"
%>
<%@Import NameSpace="System.Data"
%>
<%@Import NameSpace="System.Data.SqlClient"
%>
<script Language="C#"
runat="server">
private void LoginCheck(Object sender, EventArgs E) //验证登录合法性
{
SqlConnection Conn = new SqlConnection(Application["DbConnStr"].ToString());
SqlCommand Comm = new SqlCommand();
SqlDataReader dr;
Comm.Connection = Conn;
Comm.CommandText = "select * from OaUser where LoginName='"
+ OaLoginName.Text + "'";
Comm.Connection.Open();
dr = Comm.ExecuteReader();
tmp.Text = "'"
+ OaLoginPass.Text +"'";
if(dr.Read())
{
tmp.Text = tmp.Text + "'"
+ dr["Password"].RTrim() +"'";
String tmpstr = "1 ";
if(dr["Password"] == tmpstr) //登录成功后处理语句
{
tmpl.Text = "Login success!";
}
else
//密码不正确时处理语句
{
tmpl.Text = "Password wrong!";
}
}
else
//用户名不存在时处理语句
{
tmpl.Text = "user not exist!";
}
dr.Close();
}
</script>