4
Reply

how to compare 2 values are equal or not

Durga Velusamy

Durga Velusamy

Jul 7 2015 5:38 AM
442
the below code shows message as deleted successfully after delete data from database its fine. but
also it shows same message even the data not in the table.
 
now i need compare empno from database  and my value of empno i.e passing from frontend textbox are equal.
 
if equl means then only permit to delete query to delete.
else
means it need to show  message as Data Not in Table
 
 
[WebMethod(EnableSession = true)]
public List<Emptab> Delete(string[] datas)
{
List<Emptab> tDataList = new List<Emptab>();
Emptab tdata;
try
{
tdata = new Emptab();
tdata.empno = datas[0];
tdata.gender = datas[1];
tdata.eaddress = datas[2];
tdata.street = datas[3];
tdata.city = datas[4];
tdata.state = datas[5];
tdata.pin = datas[6];
tdata.mobile = datas[7];
tdata.mail = datas[8];
tdata.cnumber = datas[9];
tdata.ename = datas[10];
tdata.dob = datas[11];
tdata.age = datas[12];
tdata.qualification = datas[13];
tdata.depart = datas[14];
tdata.design = datas[15];
string ls_query = "";
ls_query = "delete from emptab where empno ='" + datas[0] + "'";
odcon = new OdbcConnection(con);
odcon.Open();
if (tdata.empno == datas[0])
{
comm = new OdbcCommand(ls_query, odcon);
comm.ExecuteNonQuery();
tdata.dsexecstatus = "Success";
tdata.dsmsg = "Deleted Successfully";
tDataList.Add(tdata);
}
else
{
tdata = new Emptab();
tdata.dsexecstatus = "FAIL";
tdata.dsmsg = "CANNOT ABLE TO DELETE ";
tDataList.Add(tdata);
}
}
catch (Exception)
{
throw;
}
odcon.Close();
return tDataList;
}

Answers (4)