smo

Change DataFile MaxSize using SMO

I am trying to modify the Maxsize of an sql 2008 Datafile, but the change does not happend. I`m using this code: FileGroupCollection fcoll = database.FileGroups; foreach (FileGroup grp in fcoll) { foreach (DataFile fil in grp.Files) { fil.MaxSize = 1000; } } I get no error message, but the max size of the DataFile...

R6034 When Calling SMO ExecuteNonQuery Under Machine.Specifications.ConsoleRunner

I'm using Sql Server Management Objects (SMO) in my integration tests. When I run them from Visual Studio (using TestDriven.NET or Resharper) there's no problem. But when I run from Machine.Specifications.ConsoleRunner.exe the code stops and I get this Windows dialog: R6034 - The application has made an attempt to load the C run...

Programmatically getting SQL Cluster Virtual Name

I have written a Windows service to collect information from all of our SQL servers. The service gets installed onto each server, and utilizing WMI and SMO, inserts relevant system information back to a central database. In order to get the SQL information, I use the following c# code: List<Server> sqlServers = new List<Server...

using SMO.Agent to retrieve Sql Job execution status - security issue

So ive got a C# program that fires off Sql Agent jobs using the SMO interfaces. It looks something like: Server ssis_server = new Server( new ServerConnection(SERVER_NAME, SERVER_USERNAME, SERVER_PASSWORD) ); var agent = ssis_server.JobServer; var ssis_job = agent.Jobs[job_name]; var current_status = ssis_job.Curren...

Get length of Columns using SQL Server Management Objects (SMO)

I'm writing T4 templates to generate CRUD stored procs etc I am looping through the columns of a table using SMO: For Each column As Column In table.Columns WriteLine("@" & column.Name & " " & column.DataType.Name & ", ") Next My question is simply how do I find the Length of a varchar column? There doesn't appear to be any Lengt...

C# SMO backup of remote database to local machine

Hi all, I have an application which performs backups and restores of SQL databases, this works fine on the local machine, however if I run this against a SQL server hosted on another machine I get the following error Microsoft.SqlServer.Management.Smo.FailedOperationException: Backup failed for Server '25.98.30.79'. ---> Microsoft....

Change logical database name with SMO

Hi How can I change the logical database name when restoring a database with SMO? /Viktor ...

Transfer SQL Server Objects Task using SMO connection fails on a large table

I am copying 120 tables our production database to another location using Transfer SQL Server Object task. I have also tried Script task with VB.NET Script. SQL Server 2005 is the version. All the tables get copied except one table = the error I get is -"The file exists". The table stores files like .doc, .ppt, .xls in a field of data ...

SMO missing dll on a clients

I've created an app that connects remotely to SQL Server 2008. SQL connections work and all traditional oCommand.ExecuteNonQuery(), work great! But my SMO class using server.ConnectionContext.ExecuteNonQuery(scriptfile); ERROR: missing batch parsing.dll . I can't install these independent utils on a client machines, and then take them ...

EnumAvailableServers(false) of SMO in SQL 2008 cluster is returning zero records ??

Call to EnumAvailableServers(false) is reurning zero list of sql instances in the windows 2008 sp2 cluster having sql 2008 sp1 setup. Firewall was disabled.. What are the reasons for its failure?? ...

SQL Server SMO Database Enumeration returns inexisting database

I'm enumerating all databases of an SQL Server 2005 instance using SMO like as shown below and it returns a non existing database (it was existing in the past). Using conn As SqlConnection = New SqlConnection(_connectionString) conn.Open() Dim smoConnection As New ServerConnection(conn) Dim srv As Server = New Server(smoCo...

How can I drop a SqlServer Backup Device using SMO in C#?

I can drop a SqlServer Backup Device using SQL-DMO using the following pseudo-code: SQLDMO.SQLServer2 server = New SQLDMO.SQLServer2(); server.Connect("myserver"); server.BackupDevices.Remove("mybackupdevice"); File.Delete(mybackupdevicephysicallocation); SMO.Server.BackupDevices does not appear to have a Remove() method, so how can I...

Using C# & SMO, how do I add a backup device to a SQL Server?

I know how to use C# and SMO to create a file backup on a SQL Server: public void BackupDatabase(Microsoft.SqlServer.Management.Smo.Server server, string databaseName, string backupFilename, string backupName, string backupDescription) { Backup backup = new Backup(); back...

Building a generic page "Query Analyzer" like in Asp.net with SMO

Hello, I'm build a web page in ASP.net is supposed to work just like Query Analyzer. It has basically a textarea to input the sql command, and an Execute button. I'm using SMO to execute the command in the database, as follows: //Create object SMO Microsoft.SqlServer.Management.Smo.Server server = new Microsoft.SqlServer.Management.S...

Error when using Transfer in Microsoft SMO namespace

Hi, I'm writing an ASP.NET app in c# that will allow users to upload databases from local sql 2005 server to a remote sql server. The code does not run directly on the local sql server, it runs on an adjacent server. The error I receive when I run the code is: ERROR : errorCode=-1073659874 description=The file name "C:\Documents and...

Issues in Convergence of Sequential minimal optimization for SVM

I have been working on Support Vector Machine for about 2 months now. I have coded SVM myself and for the optimization problem of SVM, I have used Sequential Minimal Optimization(SMO) by Mr. John Platt. Right now I am in the phase where I am going to grid search to find optimal C value for my dataset. ( Please find details of my project...

Interacting with Sql Server jobs programmatically

I would like to be able to interact with a Sql Server job programmatically through a web page. What is the best way to do this? Through SMO? The job will take a long time to run, so it needs to fire and forget, and I would also like to be able to stop it. If SMO, can anybody point me to an easy tutorial? Google gave me some fairly bas...

Change SQL SERVER EXPRESS 2008 TCP port with Microsoft.SqlServer.Management.Smo

I need to change the default port(1433) of SQL EXPRESS 2008 instance in c#. ...

C# and Linq: Generating SQL Backup/Restore From Code

I'm working with a C# and Linq to SQL Winforms app and needed to integrate backup and restores through the program. I used SMO and got it working pretty smoothly. The issue, however, is that the app is deployed using ClickOnce, which I like very much - but since I had to include the dll's the download size jumped from 3mb => 15mb. I know...

I can no longer attach database to SQL 2008 server named instance

My program has been working for a long time. After trying to use SMO in my program to do a database restore I can no longer attach my database to my named instance. I keep getting the following: "Cannot open user default database. Login failed.\r\nLogin failed for user ...". At first I could not attach to it in Management Studio eith...