troubleshooting Question

C# .NET Execute SQL Script WITHOUT SMO

Avatar of ChrisMDrew
ChrisMDrew asked on
23 Comments1 Solution3951 ViewsLast Modified:

I have a project which needs to create an SQL Database probably on a remote SQL Server.  I do this by executing a few SQL scripts. (.sql file)  

Currently I do this using the Microsoft.SqlServer.Management.Sm dll (SQL Server management Objects) but I have a problem when it comes to deploying the application.

I am using the Visual Studio 2008 installer project and there is no facility that I can see to add SMO as a dependancy and get the installer to download the correct version - there is a 32 and 64 bit version of SMO.

My question is therefore broken into 2 parts.

1> Is it possible to execute a script other than using SMO in the case where Microsoft SQL Server is NOT installed on the local PC?  My current code is:-

SqlConnection connection = new SqlConnection(_dbConnection.ConnectionString);
Server server = new Server(new ServerConnection(connection));

2> If this is not possible, how can I get SMO to be included in my installation and install the correct version using the Visual Studio installer project?

Thanks for any help - this is quite urgent!!

Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 23 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 23 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros