6
Answers

textbox value doest not inserted in asp.net

this is my code. i am inserting the value in database.but topic column is always empty userby and date is inserted properly. tell me what i have to do  so that all the values can be inserted.
 
try
{
cn.Open();

string sql1 = "insert into Topics(Topic,UserBy,Date)values('" + TextBoxScrap.Text + "','" + Session["uname"].ToString() + "','" + DateTime.Now.ToString() + "')";

SqlCommand cmd = new SqlCommand(sql1, cn);
cmd.ExecuteNonQuery();
cn.Close();
TextBoxScrap.Text = "";

}
catch (Exception ex)
{
Response.Write(ex.ToString());
}

Answers (6)