Home > DeveloperSection > Forums > can't store value of text area in database in comment column it store multiline?
jayprakash sharma
jayprakash sharma

Total Post:117

Points:821
Posted on    December-22-2014 10:42 PM

 ASP.Net C# 
Ratings:


 1 Reply(s)
 552  View(s)
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();



Pravesh Singh
Pravesh Singh

Total Post:101

Points:709
Posted on    December-23-2014 5:23 AM

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

Don't want to miss updates? Please click the below button!

Follow MindStick