Click here to Skip to main content
15,895,423 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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;

}

}
Posted

1 solution

Before you test following condition
C#
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
C#
if(dt.Rows.count > 0){
after that you add your condition.

Hope be helpful,
Theingi.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900