Click here to Skip to main content
15,898,134 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
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
Posted

hi,

see This

good luck

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

Then, create your SQL query as normal, using an IN clause and the string you made earlier:
SQL
SELECT * FROM myTable WHERE key IN ('AA5GTS','JK2UTD')

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.
 
Share this answer
 
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....
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900