Click here to Skip to main content
15,913,027 members
Please Sign up or sign in to vote.
1.00/5 (4 votes)
See more:
Okay I saw an application that has this amazing feature. It lets you run SQL codes directly on the application without having to launch SQL management studio. Of course you would have to know the the table definitions and all to use this...

I'm working on an application and I want to implement this idea. This is because I want to save frequently needed SQL scripts somewhere on the server e.g 10 Youngest Employees, Highest Paid Employees etc... You select a script and it runs...

I will like a solution that runs just like what Microsoft Management Studio provides that the save as option when you right click the results...

I know the disadvantages of this so I'll write a query that would ensure only a SELECT statement would run...

Thanks guys...

What I have tried:

I might have tried nothing yet
Posted
Updated 25-Jan-17 23:11pm
v2
Comments
Richard MacCutchan 25-Jan-17 6:14am    
So what is your question?

1 solution

Simply provide a textbox then execute the contents of that textbox against the database. You can use ado.net to do this

Executing a Command[^]

change the CommandType to "Text" and set the CommandText property to be YourSQLBox.Text.
 
Share this answer
 
Comments
Akinloluwa 26-Jan-17 3:58am    
Okay great... I'll do this, then fill the data in a gridview and add an export to excel button. I'll probably also run a check for insert, delete, update and join statements so that data is not manipulated... That quite sums it. Really... thanks...

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