How To Update A Column In A DataGrid Using C#.NET? I am getting InvalidCastException as (Specified cast is not valid) while updating 2nd column in a datagrid? Id,firstname,lastname are the three columns of my datagrid respectively. I wanted to edit the second column(lastname) and update it. I did the following code in DataGrid's updatecommand(),but failed to update ! Int varid=(int)DataGrid1.DataKeys[e.Item.ItemIndex]; TextBox lnm=(TextBox)e.Item.Cells[2].Controls[0]; string str=lnm.Text ; SqlCommand cmd=new SqlCommand("update customer set lastname='" + str + "' where id=" + varid + "",con); cmd.ExecuteNonQuery(); DataGrid1.EditItemIndex=- 1; DataGrid1.DataBind();
2 14596When we are running the Application, if any errors occur in the Stored Procedure then how will the server identify the errors?
HCL,
5 9150
What are the classes in System.Data.Common Namespace?
What are the ado.net components?
What is the difference between sqlcommand and sqldataadapter?
Explain the difference in an abstract class and an interface?
What are the uses of Stored Procedure?
What is difference between datareader and dataadapter?
What are the Features and disadvantages of dataset
Explain how to call the sql commands asynchronously in ado.net version 2.0?
What provider ado.net use by default? Explain the role of data provider in ado.net?
Which architecture does Datasets follow?
What are the usages of the command object in ado.net?
What are the pre-requisites for connection pooling?
What do you mean by performing asynchronous operation using command object?
How to read data with the sqldatareader ?
What are all components of ADO.Net data provider?