| |

VerySource

 Forgot password?
 Register
Search
View: 720|Reply: 5

How to search by database and return a result by condition? (Already link normally)

[Copy link]

1

Threads

2

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 Invalid IP Address

Post time: 2020-1-23 13:20:01
| Show all posts |Read mode
Currently the link is ready. The function to be implemented is based on Cname.text. Search table category
There are only 2 fields in the category table, Cname and CID (pk)
How to make the program get the CID corresponding to Cname?
Reply

Use magic Report

1

Threads

16

Posts

10.00

Credits

Newbie

Rank: 1

Credits
10.00

 China

Post time: 2020-2-20 15:00:01
| Show all posts
select * from category where cname = '"&cname.text&"' ??? Wouldn't it be that simple, what is the relationship between the two fields in your database?
Reply

Use magic Report

0

Threads

3

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

Post time: 2020-2-21 21:00:01
| Show all posts
Didn't understand, based on the string Cname.text itself, or the content of this text file?
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-2-22 11:45:02
| Show all posts
select * from category where cname = '"&cname.text&"'
This is based on the content of cname.text as the search criteria, which is your cname field.
In this way, can not take out the corresponding id.
Reply

Use magic Report

0

Threads

2

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-2-22 20:45:01
| Show all posts
Better to add cname.text.trim
Reply

Use magic Report

0

Threads

2

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-2-23 09:00:01
| Show all posts
1.Construct a datatable
Dataadapter.fill (datatable)
3, for each row in datatable
4, datatable.rows (i) ("CID") is every CID found
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list