Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

datatable column length

Status
Not open for further replies.

HappyProgrammer

Programmer
Oct 15, 2003
4
US
Hello,

I have a datatable which was populated from a flat file by looping through it adding 1 row at a time to the datatable. Once that is done the datatable is then bound to a datagridview for display on a form.

I would like to add an option to write the data to a sql server database. It would create a new table and create the fields based on the column names in the datatable. I know how to create a sql table and add columns based on the datatable and then insert records. When creating the columns in the sql table I would like to make them somewhat "smart". By "smart" I mean I would like to figure out what the maximum string length in each column is in the datatable and adjust the datatype in the sql table accordingly. ie. The max string length of column 1 is 260 the datatype becomes varchar(275), column 2 max length is 1200 and datatype becomes varchar(1300), etc. These numbers are just estimates but the amount of text in each column can vary considerably.

I am open to any suggestions. Maybe datatable isn't the way to go?

Thank you
 
nothing impossible. you will need to code the implementation yourself that's all.

Jason Meckley
Programmer
Specialty Bakers, Inc.

faq855-7190
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top