Click here to Skip to main content
15,890,579 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Why the error is comming after running this program in localhost.

Error - Cannot perform '=' operation on System.Int32 and System.String.


My cs program is given below

void del(Object Sender, EventArgs e)
{
string agent = Request.QueryString["CODNO"];
string sa=txtACode.Text.Trim();
int r=0;
con.Open();
DataRow []rs;
rs=ds.Tables["joining"].Select("agent='" + sa + "'");
//rs=ds.Tables["joining"].Select("agent='" + sa + "'");
r=rs.Length;
if (txtACode.Text=="")
{
com=con.CreateCommand();
com.CommandText="delete * from joining where agent='" + agent + "'";
}
else
{
if(r==0)
{
System.Web.UI.WebControls.Label lbl1=new System.Web.UI.WebControls.Label();
lbl1.ForeColor=System.Drawing.Color.Blue;
lbl1.BackColor=System.Drawing.Color.Yellow;
lbl1.Text="Please enter a velid cerification number to DELETE";
ph1.Controls.Add(lbl1);
}
else if(r>0)
{
DataRow dr;
dr=rs[0];
com=con.CreateCommand();
com.CommandText="delete * from joining where agent='" + sa + "'";
}
else
{
System.Web.UI.WebControls.Label lbl1=new System.Web.UI.WebControls.Label();
lbl1.ForeColor=System.Drawing.Color.Blue;
lbl1.BackColor=System.Drawing.Color.Yellow;
lbl1.Text="No Such Record Found";
ph1.Controls.Add(lbl1);
}
}
try
{
com.ExecuteNonQuery();
System.Web.UI.WebControls.Label lbl1=new System.Web.UI.WebControls.Label();
lbl1.ForeColor=System.Drawing.Color.Blue;
lbl1.BackColor=System.Drawing.Color.Yellow;
lbl1.Text="Record DELETED";
ph1.Controls.Add(lbl1);
}
catch(Exception ex)
{
}
con.Close();
}
Posted
Updated 15-Jan-12 23:42pm
v2
Comments
lukeer 16-Jan-12 5:59am    
What is ds?
It's not declared prior to using its Tables[] property.
Shahin Khorshidnia 22-Mar-12 15:46pm    
What is agent Data type in your database? is it int?

In which particular line, you are getting that error.

you can try
string agent = Request.QueryString["CODNO"].ToString();


but it would be great if you specify the line number
 
Share this answer
 
v2
Comments
Janardan Pandey 16-Jan-12 5:52am    
I am getting error in this line

rs=ds.Tables["joining"].Select("agent='" + sa + "'");
prasenjeit 24-Jan-12 8:38am    
sorry for the late reply.
If yet not solved, can you try
rs=ds.Tables["joining"].Select("agent=" + sa ); i.e removing the single quotes
May be your DataSource have empty column
 
Share this answer
 

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

  Print Answers RSS


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