using System.Data.SqlClient;
using Microsoft.SqlServer;
using Microsoft.SqlServer.Management;
using Microsoft.SqlServer.Management.Smo;
using Microsoft.SqlServer.Management.Common;
using System.IO;
public static void run(string script)
{
try
{
using (SqlConnection c = new SqlConnection(decryptedConnectionstring))
{
c.Open();
ServerConnection connection = new ServerConnection(c);
Microsoft.SqlServer.Management.Smo.Server server = new Server(connection);
try
{
server.ConnectionContext.ExecuteNonQuery(script);
}
catch (Exception ex)
{
' custom err catching
}
}
}
catch (Exception ex)
{
' custom err catching
}
}
}
}
|