Hi,
How to increase column LENGTH in System.Data.DataTable using C#.
Excel sheet cell 593 LENGTH.
Regards,
Pratik
Hi,
How to increase column LENGTH in System.Data.DataTable using C#.
Excel sheet cell 593 LENGTH.
Regards,
Pratik
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Vijay Pratap SinghRank #381 · 6.6K reputationPosted Jul 18, 2024, 4:32 AM EDT
To increase the length, you need to set the MaxLength property value.
using System; using System.Data; class Program { static void Main() { // Create a new DataTable. DataTable table = new DataTable("ExampleTable"); // Add a new DataColumn. DataColumn column = new DataColumn("ExampleColumn", typeof(string)); // Set the MaxLength to 593. column.MaxLength = 593; // Add the column to the DataTable. table.Columns.Add(column); // Now you can add rows with string values up to 593 characters long. DataRow row = table.NewRow(); row["ExampleColumn"] = new string('a', 593); // Adding a string with 593 characters. table.Rows.Add(row); // now you can Display the length of the first row's column value. } }Hope this will help.