Click here to Skip to main content
15,886,078 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
store a data that is only words like a news that contains many word. what should be the type of column or how i can do this?
Posted

 
Share this answer
 
Comments
Harshit Wadhera 25-Jan-15 19:44pm    
yeah i have use that but it giving me an error "Incorrect syntax near h' is too long. Maximum length is 128."
deepakdynamite 27-Jan-15 6:07am    
Varchar(MAX) will work... Send your query here
When you create the table you have to define a column length that is long enough to store the data you're going to insert. Seems that the column you're trying to insert into is limited to 128 characters only.

To change the column length in the table you can use ALTER TABLE[^] command. So something like:
SQL
ALTER TABLE MyTableName ALTER COLUMN MyColumnName nvarchar(MAX);
 
Share this answer
 
String sql = "INSERT INTO News ( Category,Matter,Subject,date ) VALUES  (@Category,@Matter,@Subject,@date)";
       SqlCommand cmd = new SqlCommand(sql, con);
       cmd.Parameters.Add("@Subject", SqlDbType.VarChar, 100).Value = txtsub.Text;
       cmd.Parameters.Add("@Matter", SqlDbType.VarChar, 8192).Value = txtnews.Text;
       cmd.Parameters.AddWithValue("@Category", dropdwncate.SelectedValue);
 
Share this answer
 
String sql = "INSEART INTO News( Category, Matter, Subject,data)VATUES
<@category,@mater,@subject,@data)";>
Sql Command cmd = new Sql Command(spl,com);
cmd. Parameters.Add("@subject", Sql Db Type.Varchar,500).Value=txtsub.Text;
cmd.parameters.AddWithValue("@Category", dropdwncatedValue);
 
Share this answer
 
v2
Comments
Deepu S Nair 3-Feb-15 0:42am    
Repost of solution 5 and its not clear too.Please remove it

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900