从文件读取 - 只将新数据放入SQL表中 [英] Read from file - put only new data into SQL table
问题描述
大家好,
我有一个不断添加记录的文件。我创建一个应用程序,一天2或3次,获取文件,使用TextFieldParser读取并将数据放入SQL表。
我的问题是:第一次,所有数据都插入到SQL表中。第二次我需要只插入新数据。
这是最好的方法吗?
最好的问候
我的尝试:
我创建了一个临时表到我的原始,并尝试使用NOT IN语句只有非插入数据。但是,我必须在TEXT变量上使用控件,根据我的理解,NOT IN不起作用。
你有几个选择:
- 在使用您的应用程序成功读取文件内容后清空文件内容
- 在数据库中记录最后一个文件大小,然后,从这样的位置开始读取
- ...
Hi everyone,
I have a file that continually are added records. I create an application that, 2 or 3 times in a day, take the file, read with a TextFieldParser and put data into a SQL Table.
My problem is: the first time, all data are insert into SQL Table. The second time I have need that only new data are insert.
Which is the best way to do this?
Best Regards
What I have tried:
I created a temporary table to my original and tried using NOT IN statment to have only data that are not insert. But, I have to use the control on a TEXT variable, and from what I understand, NOT IN does not work.
You have several options:
- Empty the file content after having succesfully read it with your application
- Record in your database the last file size and, next time, start reading from such a position
- ...
这篇关于从文件读取 - 只将新数据放入SQL表中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!