954,514 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

How to validate imported excel data header in vb.net

Hi,
I have this code that will import the excel sheet to the datatable then inserts it in the database, but I have this problem.
I have set the HDR to yes so that the first row will be considered as its header, but the problem now is that if the first row is null, the datatable will automatically named it's header as f1,f2 and so on. how can I set the header as null if the first row is null? so I can validate it afterwards..

thanks

jbutardo
Junior Poster in Training
73 posts since Jan 2012
Reputation Points: 8
Solved Threads: 1
 

Let me get this right. You have a dataset in an Excel spreadsheet that may or may not have the field names in the first row. Why not just open it with Hdr=No and examine the first record (row) in your code? If there is a row header then you can close it and reopen it with Hdr=Yes.

Reverend Jim
Posting Shark
Moderator
1,167 posts since Aug 2010
Reputation Points: 253
Solved Threads: 159
 

Either that or, after you have loaded the table, open its tabledef and check the field name of each field, changing if necessary.

ChrisPadgham
Posting Pro in Training
413 posts since Sep 2009
Reputation Points: 102
Solved Threads: 78
 

Anyway I solved my problem now, in excel, even if the HDR is set to YES, excel will still create it's own header if there is no value on the first row.. So I really have to deal with that situation and create a validation for that, Thanks for the replies anyway..

jbutardo
Junior Poster in Training
73 posts since Jan 2012
Reputation Points: 8
Solved Threads: 1
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: