在C#应用程序中包含MSSQL查询编辑器 [英] Include MSSQL query editor in your C# application

查看:247
本文介绍了在C#应用程序中包含MSSQL查询编辑器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好的,我看到了一个具有这个神奇功能的应用程序。它允许您直接在应用程序上运行SQL代码,而无需启动SQL管理工作室。当然你必须知道表定义和所有使用它...



我正在处理一个应用程序,我想实现这个想法。这是因为我想在服务器上的某个地方保存经常需要的SQL脚本,例如10个最年轻的员工,最高薪的员工等......你选择一个脚本然后运行...



我想要一个解决方案,就像Microsoft Management Studio提供的那样,当您右键单击结果时,另存为选项...



我知道这样做的缺点所以我会编写一个查询来确保只运行一个SELECT语句...



谢谢大家...



我尝试过的事情:



我可能还没有尝试过任何事情

解决方案

只需提供一个文本框,然后针对数据库执行该文本框的内容。您可以使用ado.net来执行此操作



执行命令 [ ^ ]



将CommandType更改为Text并将CommandText属性设置为YourSQLBox.Text。

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

解决方案

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.


这篇关于在C#应用程序中包含MSSQL查询编辑器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆