Click here to Skip to main content
15,901,368 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
error is giving at cmd.ExecuteNonQuery();





C#
protected void gvDetails_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {

        int userid = Convert.ToInt32(gvDetails.DataKeys[e.RowIndex].Value.ToString());
        //ring user = gvDetails.DataKeys[e.RowIndex].Values["UserName"].ToString();

        string username = gvDetails.DataKeys[e.RowIndex].Values["U_name"].ToString();
        //string imagename = gvDetails.DataKeys[e.RowIndex].Values["ImageName"].ToString();

        TextBox txtU_Email = (TextBox)gvDetails.Rows[e.RowIndex].FindControl("txtU_Email");
        TextBox txtImageName = (TextBox)gvDetails.Rows[e.RowIndex].FindControl("txtImageName");
        TextBox txtDescription = (TextBox)gvDetails.Rows[e.RowIndex].FindControl("txtDescription");
        TextBox txtCategoryName = (TextBox)gvDetails.Rows[e.RowIndex].FindControl("txtCategoryName");

        TextBox txtADshop_name = (TextBox)gvDetails.Rows[e.RowIndex].FindControl("txtADshop_name");
        TextBox txtADShop_Address = (TextBox)gvDetails.Rows[e.RowIndex].FindControl("txtADShop_Address");
        TextBox txtADshop_city = (TextBox)gvDetails.Rows[e.RowIndex].FindControl("txtADshop_city");
        TextBox txtADshop_mob = (TextBox)gvDetails.Rows[e.RowIndex].FindControl("txtADshop_mob");
        TextBox txtADshop_Email = (TextBox)gvDetails.Rows[e.RowIndex].FindControl("txtADshop_Email");
        TextBox txtAreaName = (TextBox)gvDetails.Rows[e.RowIndex].FindControl("txtAreaName");
        TextBox txtstartddate = (TextBox)gvDetails.Rows[e.RowIndex].FindControl("txtstartddate");
        TextBox txtendddate = (TextBox)gvDetails.Rows[e.RowIndex].FindControl("txtendddate");
        TextBox txtImagePath = (TextBox)gvDetails.Rows[e.RowIndex].FindControl("txtImagePath");
        TextBox txtdiffrence = (TextBox)gvDetails.Rows[e.RowIndex].FindControl("txtdiffrence");
        con.Open();
        
        
        OleDbCommand cmd = new OleDbCommand("UPDATE LOGIN u ,SlideShowTable s SET u.U_Email = '" + txtU_Email.Text + "',s.ImageName='" + txtImageName.Text + "',s.Description='" + txtDescription.Text + "',s.CategoryName='" + txtCategoryName.Text + "',s.ADshop_name='" + txtADshop_name.Text + "',s.ADShop_Address='" + txtADShop_Address.Text + "',s.ADshop_city='" + txtADshop_city.Text + "',s.ADshop_mob='" + txtADshop_mob.Text + "',s.ADshop_Email='" + txtADshop_Email.Text + "',s.AreaName='" + txtAreaName.Text + "',s.startddate='" + txtstartddate.Text + "',s.endddate='" + txtendddate.Text + "',s.ImagePath='" + txtImagePath.Text + "',s.diffrence='" + txtdiffrence.Text + "' where s.U_id=" + userid + " and u.U_id= " + userid, con);



        cmd.ExecuteNonQuery();
        con.Close();
        lblresult.ForeColor = Color.Green;
        lblresult.Text = username + " Details Updated successfully";
        gvDetails.EditIndex = -1;
        BindEmployeeDetails();
    }
Posted
Updated 17-Apr-13 22:16pm
v2

Hi,

What is the data type used in database for mobile,start date and end date columns, may be bcoz those columns it is giving error. check once...
 
Share this answer
 
Comments
Amirsalgar1 18-Apr-13 4:40am    
memo for start and end date
and number for mobile
Rockstar_ 18-Apr-13 4:51am    
then convert the mobile textbox value to integer
Amirsalgar1 18-Apr-13 4:53am    
sir ,
i tried by changing data type integer to memo but still it gives me the same error
Rockstar_ 18-Apr-13 4:56am    
And What about userid data type?
Amirsalgar1 18-Apr-13 4:56am    
autonumber
You should use parameteriazed queries instead, as the current on is wonerable to SQL injection attacs, plese see this:
How to avoid SQL Injection[^]

They are also easier to debug :)
 
Share this answer
 
hi,

Check below link...

http://support.microsoft.com/kb/175258[^]
 
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