问题描述
我正在寻找有关如何从 .NET Web 应用程序创建与数据库的接口以从 Excel 文件上传数据的任何最佳实践或想法我应该使用允许加载所有记录并标记错误的机制,还是应该使用在发生错误时停止加载的机制.
I am looking for any best practices or ideas on how you would create an interface with a DB from a .NET web application to upload data from Excel files Should I use a mechanism that allows all the records to be loaded and flags the errors or should I use a mechanism that stops the load when an error occurs.
我以前从来没有处理过这种类型的要求,所以任何帮助都会非常棒!
I've never had to deal with this type of requirement before so any help would be super!
谢谢
推荐答案
如果您的数据库中的数据完整性很重要,请不要导入有错误或不符合数据库验证要求的数据.
If data integrity in your DB is important, do not allow data to be imported that has errors or does not meet the validation requirements of your DB.
由于这些是 Excel 文件,用户应该很容易更正 Excel 文件中的数据,而不是尝试使用其他界面来修复数据.只需确保错误消息将用户引导至问题所在的字段并清楚地解释问题所在.
Since these are Excel files, it should be easy enough for the user to correct the data in the Excel file, instead of trying to use another interface to fix the data. Just make sure the error messages direct the user to what field is the problem and clearly explain what is wrong.
这篇关于将文件上传到数据库的最佳实践的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!