最好的方法是使用Windows应用程序自动读取excel文件流 [英] Best way read a stream of excel files atomatically using windows application

查看:127
本文介绍了最好的方法是使用Windows应用程序自动读取excel文件流的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

基本上我需要的是解决以下问题的方法。我有一个文件夹,其中包含一组excel文件,每个文件有500-600行。我需要逐个自动读取这些excel文件,并将记录转储到数据库中的某些表中。在插入记录之前,检查一些条件。



我尝试过:



表单有两个按钮启动和停止,还有一个间隔为500的计时器。当计时器被删除时,过程稍微快一点。但问题是我无法停止进程与停止之间按钮。有没有其他合适的方法可以更快地处理它。

Hi all,
Basically what I need is a solution to the following problem. I have a folder with a group of excel files having 500-600 rows for each file .I need to read these excel files automatically one by one and dump the records to some tables in the database. Before inserting the records some conditions are checked .

What I have tried:

The form has two buttons start and stop and also a timer with an interval of 500. When the timer is removed the process is little bit faster .But the problem is that I can't stop the process in between with the stop button. Is there any other suitable way to process it faster.

推荐答案

不是你的问题的解决方案,但你有另一个问题。

从不通过连接字符串来构建SQL查询。迟早,您将使用用户输入来执行此操作,这会打开一个名为SQL注入的漏洞,这对您的数据库很容易并且容易出错。

名称中的单引号你的程序崩溃。如果用户输入像Brian O'Conner这样的名称可能会使您的应用程序崩溃,那么这是一个SQL注入漏洞,崩溃是最少的问题,恶意用户输入,并且它被提升为具有所有凭据的SQL命令。

SQL注入 - 维基百科 [ ^ ]

SQL注入 [ ^ ]
Not a solution to your question, but another problem you have.
Never build an SQL query by concatenating strings. Sooner or later, you will do it with user inputs, and this opens door to a vulnerability named "SQL injection", it is dangerous for your database and error prone.
A single quote in a name and your program crash. If a user input a name like "Brian O'Conner" can crash your app, it is an SQL injection vulnerability, and the crash is the least of the problems, a malicious user input and it is promoted to SQL commands with all credentials.
SQL injection - Wikipedia[^]
SQL Injection[^]


这是非常非常糟糕的代码。永远不要连接字符串来构建SQL命令。它让您对意外或故意的SQL注入攻击持开放态度,这可能会破坏您的整个数据库。改为使用参数化查询。



当您修复了 - 虽然您的整个应用程序 - 使用秒表类来确定该方法的哪些部分正在使用te时间,并把注意力集中在那些部分。

如果不知道这一点,我们就像你上次提出这个问题一样无法提供帮助!
That's very,very bad code. Never concatenate strings to build a SQL command. It leaves you wide open to accidental or deliberate SQL Injection attack which can destroy your entire database. Use Parametrized queries instead.

When you have fixed that - though your whole app - use the Stopwatch class to work out what part(s) of the method are using te time, and focus your attention on those parts.
Without knowing that, we are as unable to help as we were the last time you asked this question!


这篇关于最好的方法是使用Windows应用程序自动读取excel文件流的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆