使用C#在SQL Server上执行SQL脚本 [英] Execute sql script on SQL server using C#
问题描述
SQL Server 2008 R2 Express,.Net Framework 4.0,Visual Studio 2010
我正在尝试从命令提示符应用程序执行SQL脚本.我找到了示例
代码并尝试实现相同的代码.但是无法识别以下using语句.
using Microsoft.SqlServer.Management.Common;
using Microsoft.SqlServer.Management.Smo;
我缺少任何程序集参考吗?
您可能需要SQL Server随附的SDK附带的程序集. 请确保在安装SQL Server时已安装SDK . >
(截取自Google随机图片的屏幕截图,突出显示的项目是您所需要的)
默认情况下,它们位于与C:\Program Files (x86)\Microsoft SQL Server\100\SDK\Assemblies
相似的路径中.版本号可能与已安装的SQL Server版本不同.
SQL Server 2008 R2 Express, .Net Framework 4.0, Visual Studio 2010
I'm trying to execute a SQL script from a command prompt application. I found a sample
code and trying to implement the same. But the following using statements are not recognized.
using Microsoft.SqlServer.Management.Common;
using Microsoft.SqlServer.Management.Smo;
Am I missing any assembly reference ?
You likely are, you need the assemblies that are included with the SDK that comes with SQL server. Be sure you installed the SDK when you installed SQL server.
(screenshot taken from a random google image search, the highlighted item is what you need)
By default they are located at a path similar to C:\Program Files (x86)\Microsoft SQL Server\100\SDK\Assemblies
The version number may be different for the version of SQL server you have installed.
这篇关于使用C#在SQL Server上执行SQL脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!