Hi Guys, I am trying to insert data in an SQL table by executing an Insert Query.
The problem is that I need to get the column name from a cell in the selected gridview Row.
Here's the snippet:
SqlCommand cmd30 = new SqlCommand("insert into mytable ( '"+GridView7.SelectedRow.Cells[0].Text+"' , r_id) values ('"+ GridView7.SelectedRow.Cells[1].Text +"', '"+TextBox1.Text+"')",con30);
cmd30.ExecuteNonQuery();
**r_id is not a Primary Key.
The Error is get is:
Incorrect syntax near 'r_id'.
Also is it possible to get the column name of the table from a specific cell of the selected Gridview row?
That seems to be the problem.
Any Help will be appreciated.
Thanks,
Shaleen