Server _server = new Server(new ServerConnection(new SqlConnection("Data Source=xxxx;Initial Catalog=Demo3Dev;Persist Security Info=True;User ID=sa;Password=xxxx")));
Microsoft.SqlServer.Management.Smo.Login newlogin = new Microsoft.SqlServer.Management.Smo.Login(_server, "Demo3Dev"); //Specified the server (.) and the LoginName (MyUserAccount)
newlogin.DefaultDatabase = "Demo3Dev"; //Choose the default Database for the user.
newlogin.LoginType = LoginType.SqlLogin; //Choose the SQLServer Login
newlogin.Create("xxxx"); // User was created here
User _user = new User(_server.Databases["Demo3Dev"], "Demo3Dev");
_user.Login = "Demo3Dev";
_user.Create();
No comments:
Post a Comment