Click here to Skip to main content
15,888,286 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Actually in my project i have to fetch the database from different servers in a Datalist.But i have to write the query in a text box...In a Tree view i have multiple databases based on the which database i click that database will appear in datalist. please help me....
Posted

If you need to do a Union for all the tables in the different servers, try
SQL
select column1 from [server1].[table1] 
UNION
select column1 from [server2].[table2] 



Write the query in the text box and then execute this query in a Data Reader.
 
Share this answer
 
You do realize just how dangerous that is, don't you?
It's one thing to risk an SQL Injection Attack by concatenating your strings, completely another to hand complete copntrol of the SQL query to the user. What happens if they enter a query like:
SQL
DROP TABLE Customers
 
Share this answer
 
Comments
45678910 28-Jul-11 22:34pm    
yes i know that i already implemented that...if any one write query like that it gives security alert...I gave access privileages...so please help me for above problem
OriginalGriff 29-Jul-11 3:39am    
And that applies to UPDATE and INSERT statements, too?

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