tags:

views:

33

answers:

0

Hello,

I want to create a structure where in I have a source class which has got 2 funtions: MySourceClass.GetData() As Datatable and MySourceClass.GetSchema() As Datatable.

When this functions are called from my code it should accordingly go to the interface class and read data from the user selected file. For example, if the user selects an excel file then when calling MySourceClass.GetData() it should read the excel file object class and get the data however if the CSV file object class is selected then when calling MySourceClass.GetData() it should read data from CSV file.

All in all what I want to achieve is that a call to SourceClass.GetData would go and fetch the datatable by reading the appropriate file using the interface class and the interface class dictates which type of file is to be read and I dont have to pass any values into the MySourceClass,GetData() function like FileName, FilePath, FileType, HasHeaderRow, Connection String etc... as the interface class would already have all that information...

I am quite new and thick to this and would therefore appreciate some kind of example to explain how can I achieve this....

Something like this

Public Interface ReadFile Function GetData() As Datatable End InterfaceClass ReadCsV implements ReadFileEnd ClassClass ReadExcel implements ReadFileEnd ClassClass MySource Public Function GetData() as Datatable 'This would read the interface and 'decide wether to read from CSV file or 'from excel file and accordingly returm the datatableEnd Class The reason for this whole exercise is because all I want to finally achieve is that user can select multiple sources like a combination of CSV file, excel file, delimited file, database tables and I allow them to map this data to the existing database tables and save the data from the file in that table.

Therefore creating a object structure which has Import Job at the topmost level, within it a Import Task Collection object which has import task object containg Source Class, Field Mapping Collection Class, Destination table details class.

Therefore what would happen is when i do ImportJob.ImportTaskCollection(i).ImportTask.DataSource.GetData() it will read the appropriate file and return the datatable

All your help is very much appreciated and hopefully someday i would be in a postition to help others...

Thanks.