验证用户的价值 [英] validation for user for values

查看:76
本文介绍了验证用户的价值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当用户输入错误的用户ID时,我想验证用户,记录应首先与数据库值匹配,然后检查用户ID是否匹配(如果用户不匹配),则应该给出错误的用户ID信息

我已经厌倦了它的代码,但是它给了我错误,请告诉我正确的代码


//按钮点击事件,我将此函数称为
BindSponcor();

//我写的函数


私有void BindSponcor()
{
DataTable dt = new DataTable();
字符串查询="SELECT * FROM Registration_Master WHERE sponcorid =""+ txtsponcorid.Text.ToString()+"'';
dt = DBHelper.SQLHelper.getTable(query.ToString());
试试
{
if((dt.Rows [0] ["sponcorid"].ToString()== txtsponcorid.Text)&&(dt.Rows [0] ["sponcorname"].ToString()== txtsponcorname.Text.ToString() ))
{



}
其他
{
字符串csname ="PopupScript";
类型cstype = this.GetType();
ClientScriptManager cs = Page.ClientScript;
如果(!cs.IsStartupScriptRegistered(cstype,csname))
{
字符串cstext ="confirmVerify()";
cs.RegisterStartupScript(cstype,csname,cstext,true);
}
}


}
catch(ex ex例外)
{
扔前;

}

}

i want to validate user when he give wrong userid the record should first match with database value and then check it userid is matching if user is not matching then the it should give message wrong userid

i have tired its code but it gives me error please tell me the correct code


//button click event i call this function
BindSponcor();

//function i wrote


private void BindSponcor()
{
DataTable dt = new DataTable();
string query = "SELECT * FROM Registration_Master WHERE sponcorid=''" + txtsponcorid.Text.ToString() + "''";
dt = DBHelper.SQLHelper.getTable(query.ToString());
try
{
if ((dt.Rows[0]["sponcorid"].ToString() == txtsponcorid.Text) && (dt.Rows[0]["sponcorname"].ToString() == txtsponcorname.Text.ToString()))
{



}
else
{
String csname = "PopupScript";
Type cstype = this.GetType();
ClientScriptManager cs = Page.ClientScript;
if (!cs.IsStartupScriptRegistered(cstype, csname))
{
String cstext = "confirmVerify()";
cs.RegisterStartupScript(cstype, csname, cstext, true);
}
}


}
catch (Exception ex)
{
throw ex;

}

}

推荐答案

在测试以下条件之前
Before you test following condition
if ((dt.Rows[0]["sponcorid"].ToString() == txtsponcorid.Text) && (dt.Rows[0]["sponcorname"].ToString() == txtsponcorname.Text.ToString()))
{



}
else
{

确保数据记录在数据表中是否存在.添加条件

make sure data record have or not in the datatable. Add the condition

if(dt.Rows.count > 0){

之后,添加条件.

希望对您有所帮助,
Theingi.

after that you add your condition.

Hope be helpful,
Theingi.


这篇关于验证用户的价值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆