| |

VerySource

 Forgot password?
 Register
Search
View: 676|Reply: 4

How to write statement when calling tableadapter of a dataset

[Copy link]

1

Threads

3

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

Post time: 2020-2-17 10:30:01
| Show all posts |Read mode
As the title, I built a data set and built a tableadapter in it. The statement assumes: select a, b, c, d, e from table1.
In the form, I pulled a datagridview and bound the tableadapter as follows
dsBillTableAdapters.ICStockBillTableAdapter da = new dsBillTableAdapters.ICStockBillTableAdapter ();
            this.iCStockBillTableAdapter.Fill (this.dsBill.ICStockBill);

You can get the results found by selecting a, b, c, d, e from table1. But now I want to add where a = 1 to the end of the statement when I call it. What should I do?
Reply

Use magic Report

0

Threads

17

Posts

10.00

Credits

Newbie

Rank: 1

Credits
10.00

 China

Post time: 2020-4-20 14:15:01
| Show all posts
Handle when selecting. The condition of WHERE a = 1 is added to the SQL statement.

SELECT a, b, c, d, e FROM table1 WHERE a = 1
Reply

Use magic Report

1

Threads

3

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

 Author| Post time: 2020-4-20 20:30:02
| Show all posts
I do n’t want to deal with it when I select it, because I have a bunch of filter conditions on the form, written as a string, and I want to add it after the select
Reply

Use magic Report

0

Threads

41

Posts

13.00

Credits

Newbie

Rank: 1

Credits
13.00

 Egypt

Post time: 2020-4-26 09:45:02
| Show all posts
Front SQL

string sWhere = "not exists (select 1 from table1 tb where table1. primary key = tb. primary key and tb.a = 1)"

Add this to the condition
Reply

Use magic Report

1

Threads

3

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

 Author| Post time: 2020-4-29 10:15:01
| Show all posts
How to add?
Now I am forced to write the statement as a stored procedure, as exec (@a), and then pass the parameters to the stored procedure, such as and a = 1, then @ a = 'select a, b, c, d, e from table where 1 = 1 '+ parameter
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