| |

VerySource

 Forgot password?
 Register
Search
Author: froginwell

Can I use DataTable for SQL difference?

[Copy link]

1

Threads

7

Posts

8.00

Credits

Newbie

Rank: 1

Credits
8.00

 China

 Author| Post time: 2020-3-20 21:30:02
| Show all posts
as follows
If you set a name for DT

string sql = "select a. *, b. * from sqltb a left join" + dt.tablename + "b on a.id = b.id";

=============
This does not work, the object name is invalid
Reply

Use magic Report

0

Threads

9

Posts

8.00

Credits

Newbie

Rank: 1

Credits
8.00

 China

Post time: 2020-3-21 10:45:01
| Show all posts
Seems to be impossible
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-7-26 20:30:01
| Show all posts
Can you use SQL statements to directly manipulate the DataTable and perform queries and other operations on it.
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 Invalid IP Address

Post time: 2020-7-26 23:30:02
| Show all posts
public DataSet aaa(DataTable dt)
{
    string sql ="select a.*,b.* from tba left join "+dt+" b on a.id=b.id";
}


Change it

public DataSet aaa(DataTable dt)
{
step 1:
Read tba data and write to dataTableA

step 2:
Build a dataset and merge dt and dataTableA into the dataset

step 3:
Establish a relationship. From your SQL, dataTableA is the parent table and dt is the slave table

In this way, you can access whatever data you want

}
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