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

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.

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

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..

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.