CAN'T STORE VALUE OF TEXT AREA IN DATABASE IN COMMENT COLUMN IT STORE MULTILINE?

jayprakash sharma

Total Post:117

Points:821
Posted by  jayprakash sharma
C# 
 867  View(s)
Ratings:
Rate this:

HTML code

 <textarea id="commentarea" name="S1" cols="30" rows="5"></textarea>

C# code

SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["RegistrationConnectionString"].ConnectionString);

 

conn.Open();

 

string insertcmnt = "insert into Comment(Comment) values(@comment)";

 

   SqlCommand com = new SqlCommand(insertcmnt, conn);

        com.Parameters.AddWithValue("@comment", TextBoxMode.MultiLine.ToString());

        com.ExecuteNonQuery();

        Response.Write("Commented successfully");

        conn.Close();

  1. Pravesh Singh

    Post:101

    Points:709
    Re: can't store value of text area in database in comment column it store multiline?

    Hi jai


    You are storing the name of the MultiLine value from the TextBoxMode enum. You should be referencing the textarea object. Try this

     com.Parameters.AddWithValue("@comment", commentarea.Text);

    Also, the textarea in the html is missing the runat attribute

    <textarea id="commentarea" name="S1" cols="30" rows="5" runat="server"></textarea>

      Modified On Apr-12-2016 12:18:37 AM

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!