Monday, March 12, 2012

Programming SQL Express

Hey, i have an installer that places ms sql express onto a machine. thats is fine. i want to create a post setup application that runs after ms sql server is installed. what for example i want to do is be able to create a user and have the DB allow remote connections. i can provide instructions for a 'peon' to make the required post setup changes but i want to see if i can cover that with an application. thanks

Charles Rezsonya

Write this as T-SQl and then either write code that calls into the database and execute the script(call this code from your installer), or include a .sql file with the script as part of your installation and then call that through a call to sqlcmd to execute.

Either way I recomend having a copy of the script as part of your install so that if something goes wrong you can at least walk a user through running the script by hand.

|||Hi,

These things can be easily changed using the SMO namespace:

using Microsoft.SqlServer.Management.Smo.Wmi;

(....)

ManagedComputer comp = new ManagedComputer(".");

comp.ClientProtocols["tcp"].IsEnabled = true;
(...)

Remeber to restart the service after changing this.

HTH, Jens K. Suessmeyer.

http://www.sqlserver2005.de

|||

amazing. i will certainly be trying that monday. Thanks. Keep an eye on this post incase i have add'l questions?

tia

Charles R

|||Sure, everyone who signed in for alerts (its by default in the forums will get an IM Alert and additional the email alert ( depending on the configuration)

HTH, Jens K. Suessmeyer.

http://www.sqlserver2005.de|||

hey, anyway you can show me a script that would change the server to allow tcp remote connections? what application do i run to process the script?

|||ok. i'm not finding the dll to include the smo namespace using 'using' in the sql sdk directory. and when i go to the studio and go to projects -> add reference its not listed "microsoft.sqlserver.etc etc"....... where can i download this dll? any add'l source on connecting examples?|||actually i found it on one of my other servers i installed the sdk to. so i'm including it. next really is just to get it going now :)|||

damn, but i am having a problem. i am using visual studio 2003 and when i go to about it says my .net framework is 1.1. is that a problem for the following message?

a referance to 'c:\program file\microsoft sql server\90\sdk\microsoft.sqlserver.sqlenum.dll' could not be added. this is not a valid or COM component. only assemblies with extension 'dll' and com components can be referenced. please make sure that the file is accessible, and that it is a valid assembly or com component.

|||is it possible to do this with visual studio 2003?|||

I don't believe so.

SMO is a SQL 2005 and .NET Framework 2.0 technology. I think that VS 2003 is locked into NetFx1.1. (Any VS experts can feel free to correct me.) You have a couple alternatives:

Move up to VS 2005, you can get the VS Express Editions for free if you like. They have some reduced functionality.

No comments:

Post a Comment