This is my code:
protected void txtcmd_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["connect"].ConnectionString);
SqlCommand cmd = new SqlCommand();
int ID = int.Parse(Session["Id"].ToString());
string comments = ((TextBox)statusgrdview.FindControl("txtcommt")).Text;
cmd.CommandType = CommandType.Text;
cmd.CommandText = "insert into TBL_Comments(ID,comments) " + "values("+ID+",@comments);" + "select * from TBL_Comments";
cmd.Parameters.Add("@comments", SqlDbType.VarChar).Value = comments;
statusgrdview.DataSource = GetData(cmd);
statusgrdview.DataBind();
}
private object GetData(SqlCommand cmd)
{
throw new NotImplementedException();
}

Sanjeeb LenkaPosted May 4, 2015, 6:46 AM
Akhil GargPosted May 4, 2015, 6:43 AM
Deepak RatanPosted May 4, 2015, 6:06 AM
int ID = int.Parse(Session["Id"].ToString());
Sanjeeb LenkaPosted May 4, 2015, 6:04 AM
Deepak RatanPosted May 4, 2015, 6:02 AM
ERROR
Dipankar BiswasPosted May 4, 2015, 5:58 AM
I think
SqlCommand cmd= new SqlCommand(con);
Try it..