Showing posts with label collection. Show all posts
Showing posts with label collection. Show all posts

Tuesday, March 27, 2012

Adding a loggin to a server

In DMO the server object had an add method on the Logins collection. Does anyone know how this works in SMO the logins collection does not have an add.

I have spent hours on this and just cannot figure out how to create a new login on a server using SMO. I guess I could allways script the login but there must ba a way to do this in SMO.

Thanks

You can create a login as follows:

Server srv = new Server("MyServer"); //Yukon

srv.ConnectionContext.LoginSecure = true;

srv.ConnectionContext.Connect();

srv.DefaultTextMode = false;

string lgName = "MyNewLogin";

if (srv.Logins[lgName] == null)

{

Login lg = new Login(srv, lgName);

lg.LoginType = LoginType.SqlLogin;

lg.Create("MyPassword!#");

}

Peter

Saturday, February 25, 2012

Add events as one batch

Hi,

Can I add collection of events to notification services from my .NET application?

Current implementation in my code:

Code Snippet

// create a new event and event collector

Event myEvent = new Event(application, eventClassName);

EventCollector eventCollector = new EventCollector(application, EVENT_CREATOR);

// Set field values of the event.

.

.

.

// add the event

eventCollector.Write(myEvent);

// commit the 1-event batch

eventCollector.Commit();

Let me know how can I commit collection of events at once rather than one by one.

Please give me your suggestions on this whether this can not be achieved or NOT.

Thanks in advance

Yogendran

Ah... Guys do you know where I can get the answer for this question?

Please help me.

Do you think this cann't be done?

Regards

Yogendran