Possible Duplicate:
Changing SQL Server settings programmatically
To setup a network connection between client C# application and SQL Server 2008 R2 I know what should manually do, my problems is how to do following steps in the C# code!
- Set TCP/IP protocol Enabled for a server instance like
MSSQLSERVERR2
. Restart my SQL Server engine.
I can do the other steps by SQL queries:
Add User and grant admin permission.
CREATE LOGIN momtahen WITH PASSWORD = '123' EXEC master..sp_addsrvrolemember @loginame = N'momtahen', @rolename = N'sysadmin'
Set mixed authentication mode for my SQL Server.
EXEC xp_instance_regwrite N'HKEY_LOCAL_MACHINE', N'Software\Microsoft\MSSQLServer\MSSQLServer', N'LoginMode', REG_DWORD, 2
I need C# code or SQL query that I could execute using C#.
Also I have to mention that I have seen following question and no help yet!
- Enable tcp\ip remote connections to sql server express already installed database with code or script(query)
- Enable remote connections to sql express with a script
- what are registry settings to enable TCP on SQL Server 2005 and 2008?
Thanks to them by the way. So any Idea?