C#SQL Select - 源文本文件 [英] C# SQL Select - source text file

查看:58
本文介绍了C#SQL Select - 源文本文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我需要帮助根据文本文件中的行从数据库中获取行。我有一个文本文件,我在表格中保存记录,一行只写一个键,如下所示:

AA5GTS

JK2UTD

。 ..



我在数据库中拥有相同的密钥,现在我必须从数据库中选择所有行,其中密钥位于文本文件中。怎么做以及如何在表单中显示数据,可能在 datagridview !?



感谢

Hi,

I need help abut getting rows from database based on lines in text file. I have text file in which I keep records in form unique key written one key in one line,like this:
AA5GTS
JK2UTD
...

I have the same keys in database, now I have to select all rows from database where keys are in text file. How to do that and how to show data in form, maybe in datagridview!?

Thank's

推荐答案





请参阅



祝你好运



jeremy


see This

good luck

jeremy


首先,阅读您的文本文件,并将您的密钥转换为以逗号分隔的项目列表,并用引号字符包围:

First, read your text file, and convert your keys to a comma separated list of items, surrounded by quote characters:
'AA5GTS','JK2UTD',...



然后,使用IN子句正常创建SQL查询和你之前创建的字符串:


Then, create your SQL query as normal, using an IN clause and the string you made earlier:

SELECT * FROM myTable WHERE key IN ('AA5GTS','JK2UTD')



执行您的查询,可能使用DataTable和DataAdapter,但基本上与您无关用于使用。

然后可以根据需要显示数据。


Execute your query, probably with a DataTable and a DataAdapter but basically with whatever you are used to using.
The data can then be presented as necessary.


上面的查询是正确的,但如果你想匹配字符串就像那样

您应该将该字符串拆分为表格。

并使用光标进一步实施....
Above Query Is Correct, But If You Want To Match String As Like Then
You Should Split That String As A Table.
And Use Cursor To Implement Further....


这篇关于C#SQL Select - 源文本文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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