Last post Sep 05, 2014 06:28 AM by oned_gk
Sep 05, 2014 05:38 AM|HexLord|LINK
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.Text+"' , r_id) values ('"+ GridView7.SelectedRow.Cells.Text +"', '"+TextBox1.Text+"')",con30);
**r_id is not a Primary Key.
The Error is get is:
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.
Sep 05, 2014 05:59 AM|SumoS|LINK
Why you are taking column name from gridview just provide in query,
SqlCommand cmd30 = new SqlCommand("insert into mytable ( 'column1', 'column2') values('" + r_id + "', '" + TextBox1.Text + "')",con30);
Sep 05, 2014 06:28 AM|oned_gk|LINK