smo

Reference Microsoft.SqlServer.Smo.dll

帅比萌擦擦* 提交于 2019-11-27 17:30:46
I need to use Server class which is stored in Microsoft.SqlServer.Smo.dll I don't see this assembly in usual References dialog. I have found it at C:/Program Files/Microsoft SQL Server/100/SDK/Assemblies and try to reference from there but Visual Studio throws an error "A reference 'C:/Program Files/Microsoft SQL Server/100/SDK/Assemblies/Microsoft.SqlServer.Smo.dll' could not be added. Please make sure that file is accessible, and that it is a valid assembly or COM component". What am I doing wrong? C:\Program Files\Microsoft SQL Server\100\SDK\Assemblies is the correct folder location (or C:

Programmatically retrieve SQL Server stored procedure source that is identical to the source returned by the SQL Server Management Studio gui?

二次信任 提交于 2019-11-27 17:14:33
Any pointers on how I can programmatically get exactly the identical stored procedure source from SQL Server 2005, as when I right-click on that stored procedure in SQL Server Management Studio and select modify? I'm trying using SMO, but there are some textual differences. The procedure always has CREATE, not ALTER, and there are some differences in the header, such as missing GOs in the version I'm getting programmatically. I can fix these up, but perhaps there is a better way? Again, I'm in SQL Server 2005, using SMSE. Using SMO via Visual Studio 8 2008. Update : Gotten some answers that

How to restore a database from C#

南笙酒味 提交于 2019-11-27 11:43:33
I have a SQL 2008 DB. I am running a form that backs that DB up, then tries to update it. If the update fails the idea is to restore that backup. Here is the code I am using to restore the backup. public void RestoreDatabase(String databaseName, String backUpFile, String serverName, String userName, String password) { Restore sqlRestore = new Restore(); BackupDeviceItem deviceItem = new BackupDeviceItem(backUpFile, DeviceType.File); sqlRestore.Devices.Add(deviceItem); sqlRestore.Database = databaseName; ServerConnection connection = new ServerConnection(serverName, userName, password); Server

SQL Server SMO complains of missing DLL

本小妞迷上赌 提交于 2019-11-27 01:54:20
问题 Ok, I've scoured the web, BOL, various forums and I'm no closer to an answer...hopefully you fine folks can lend a hand... We've got a dozen or so SQL Servers (some 2k, some 2005) on a network. I'm using SMO objects in a .NET application to get some standard information. My problem appears to boil down to a missing DLL - Microsoft.SqlServer.BatchParser.dll. However, this DLL did not come with the other SQL DLLs (Microsoft.SqlServer.ConnectionInfo.dll, Microsoft.SqlServer.Smo.dll, Microsoft

Reference Microsoft.SqlServer.Smo.dll

↘锁芯ラ 提交于 2019-11-26 19:02:04
问题 I need to use Server class which is stored in Microsoft.SqlServer.Smo.dll I don't see this assembly in usual References dialog. I have found it at C:/Program Files/Microsoft SQL Server/100/SDK/Assemblies and try to reference from there but Visual Studio throws an error "A reference 'C:/Program Files/Microsoft SQL Server/100/SDK/Assemblies/Microsoft.SqlServer.Smo.dll' could not be added. Please make sure that file is accessible, and that it is a valid assembly or COM component". What am I

How to list available instances of SQL Servers using SMO in C#?

雨燕双飞 提交于 2019-11-26 11:38:31
问题 Can anybody explain me what I wrong I am doing in the following piece of code: DataTable dt=SmoApplication.EnumAvailableSqlServer(true); Server sr = new Server(\"Test\"); foreach(DataBase db in sr.DataBases) { Console.WriteLine(db[\"name\"]); } It gives an exception in sr.Databases that can not be connected. 回答1: Take a look at the following links they may be helpful: Enumerate SQL Server Instances in C#, Using ODBC How to get a list of available SQL Servers using C# (MSDN) Populating a list