导入CSV文件/ EXCEL到SQL数据库asp.net数据库、文件、EXCEL、CSV

2023-09-07 01:47:23 作者:控控控控控控。#女人

我开始与asp.net Visual Studio中的项目2008 / SQL 2000(2005年以后)使用C#。

I am starting a project with asp.net visual studio 2008 / SQL 2000 (2005 in future) using c#.

最棘手的部分,我是经常存在的数据库架构的变化和导入文件的列都将有被匹配了与现有的数据库架构,因为他们可能没有一对一的匹配列名。 (有一个查找表,提供这些表的模式与列名,我会用)

The tricky part for me is that the existing DB schema changes often and the import files columns will all have to be matched up with the existing db schema since they may not be one to one match on column names. (There is a lookup table that provides the tables schema with column names I will use)

我正在探索不同的方式接近这一点,需要一些专家的意见。是否有任何现有控制措施或框架,我可以利用做任何的吗?

I am exploring different ways to approach this, and need some expert advice. Is there any existing controls or frameworks that I can leverage to do any of this?

到目前为止,我探讨的FileUpload .NET控件,以及一些第三方上传控件实现上载如 SlickUpload 但上传的应该是与其中的文件; 500MB

So far I explored FileUpload .NET control, as well as some 3rd party upload controls to accomplish the upload such as SlickUpload but the files uploaded should be < 500mb

下一部分是读我的CSV / Excel中,并解析它显示给用户,使他们能够与我们的DB模式相匹配。我看到 CSVReader 和别人,而是为Excel的更困难,因为我会需要支持不同的版本。

Next part is reading of my csv /excel and parsing it for display to the user so they can match it with our db schema. I saw CSVReader and others but for excel its more difficult since I will need to support different versions.

从本质上执行此导入的用户将插入和/或更新此导入文件的几个表。有喜欢的记录匹配,但与进口记录preVIEW其他更高级的要求,但我希望得到通过了解如何做到这一点先。

Essentially The user performing this import will insert and/or update several tables from this import file. There are other more advance requirements like record matching but and preview of the import records, but I wish to get through understanding how to do this first.

更新:我结束了使用csvReader与LumenWorks.Framework上传的CSV文件。

Update: I ended up using csvReader with LumenWorks.Framework for uploading the csv files.

推荐答案

我使用csvReader从LumenWorks.Framework上传和导入中,我创建基于进口的列存储的CSV文件到一个SQL表和DataTable。

I am using csvReader from LumenWorks.Framework for uploading and importing the csv files into a sql table and a DataTable in memory which I create based on the columns imported.

我也有用户映射的用户界面等领域,并继续通过标记每个记录的插入/更新/错误来验证和prepare数据进行导入。然后创建/填充强类型DataSet中的每个表将受到影响,并建立企业库UpdateDataset()方法插入/更新查询。

I also have the user map the fields in the ui and proceed to validate and prepare the data for import by labeling each record as insert/update/error. I then create/populate strongly typed DataSet for each table that will be affected and build the insert/update queries for Enterprise Library UpdateDataset() method.

于是我向插入/更新数据库的事务。 -

Then I submit the transaction to insert/update the database. –

映射是有4列的网格。 (导入字段名称,目标表,目标字段名,忽略,比赛状态),与刷新基于表中选择目标表名和字段名被选择。我动态填充的选择。最初选择的组合填充了1值,如果找到匹配,或者请,如果事实并非如此。忽略允许用户忽略该字段。比赛的状态是,如果一个领域进行了自动映射

The mapping is a grid with 4 columns. ( import field name, destination table, destination field name, ignore, match status), with destination table and field names being selects which refresh based on table selected. I dynamically populate the selects. Initially select combo is populated with 1 value if the match is found, or please select if it isn't. ignore allows user to ignore the field. match status is if a field was auto-mapped

 
精彩推荐
图片推荐