Wednesday, March 7, 2012

New in SQL-NS 2005 ...plz help me

hi everyone...

Iam new in sql-ns 2005 & I've been trying the last couple of days to get my first running program...but still Iam facing a problem..

I tried to run this sample which I got from one the websites...

using System;

using Microsoft.SqlServer.Management.Smo;

using Microsoft.SqlServer.Management.Nmo;

using ns = Microsoft.SqlServer.NotificationServices;

namespace My_Nc

{

class Program

{

private static Instance nsi;

private static Application a;

private const string baseDirectoryPath =

@."D:\Documents and Settings\falmalik\My Documents\Visual Studio 2005\Projects\My_Nc";

private const string nsServer = //

private const string serviceUserName = //

private const string servicePassword = //

static void Main(string[] args)

{

Server server = new Server("(local)");

// create a new instance

NotificationServices ns = server.NotificationServices;

nsi = new Instance(ns, "StockWatch");

CreateDeliveryChannel();

a = new Application(nsi, "StockWatchApp");

a.BaseDirectoryPath = baseDirectoryPath;

CreateEventClass();

CreateSubscriptionClass();

CreateNotificationClass();

CreateHostedEventProvider();

CreateGenerator();

CreateDistributor();

CreateVacuumSchedule();

a.QuantumDuration = new TimeSpan(0, 0, 15);

a.PerformanceQueryInterval = new TimeSpan(0, 0, 5);

a.SubscriptionQuantumLimit = 1;

a.ChronicleQuantumLimit = 1;

a.VacuumRetentionAge = new TimeSpan(0, 0, 1);

nsi.Applications.Add(a);

Console.WriteLine("Added application.");

nsi.Create();

nsi.RegisterLocal(serviceUserName, servicePassword);

nsi.Enable();

Console.WriteLine("Application enabled." +

Environment.NewLine);

CreateSubscriber();

CreateSubscription();

Console.WriteLine(Environment.NewLine +

"Press any key to continue.");

Console.ReadKey();

}

the problem I get when I run it is with nsi.Create(); it gives me the following message :The Notification Services operation performed is invalid.

I don't know if the problem is with the nsServer,serviceUserName,servicePassword or not?

because i tried to change them alot of times but still ...it even some times gives me the problem with nsi.RegisterLocal(serviceUserName, servicePassword);

so what are the valid values of them?

I didn't really understand :serviceUserName is the account the NS$StockWatch Windows Service will run under

so could anyone please tell me what the problem is? or even could give me or direct me to a simple sample (even without the use of SMTP) ...I even tried the MSDN samples but still

another question is that i read more than once about the eventdata file ...& that I should copy it to the event subfolder to watch it....so do I have to do this everytime I run the application or what?

forgive me for my questions which may seem silly...but this is my first time

thank you..

First of all, the best way to learn SQL NS is by reading a good book and following examples in it. Of course, it might seem that it would take much more time than learning by an example on MSDN, but... it's not true. SQL NS, while being a relatively easy-to-learn technology, is not "a piece of cake".
The best 2 books that I know (and I used one of them to learn NS) are:
http://www.amazon.com/Microsoft-Server-Notification-Services-Windows/dp/0672326647/ref=sr_1_2/103-3024305-8379809?ie=UTF8&s=books&qid=1185276090&sr=1-2
and
http://www.amazon.com/Rational-Server-Notification-Services-Guides/dp/0972688811/ref=pd_bbs_sr_2/103-3024305-8379809?ie=UTF8&s=books&qid=1185276061&sr=8-2
There are also other books (specifically on NS for SQL Server 2005), but the differences between 2000 and 2005 are negligible.
The fact is, there's a lot to know if you are the only developer for your NS project, and you can't learn it fast enough without a good book.

You are using C# classes to create all of your NS objects. Although this approach is quite valid, the SQL NS is known for its declarative programming model. That is, it is much easier to create the entire NS application using XML files (application definition file, etc.). At the same time, you can use C# for creating your custom objects, such as a custom event provider, custom content formatter, etc., if you need customization.

When you install NS on your machine, it comes with a help file. In the help, there is a tutorial. It gives you step-by-step instructions on how to build an NS application. This tutorial is also available online at
http://msdn2.microsoft.com/en-us/library/ms170337.aspx (NS for SQL Server 2005)
or http://msdn2.microsoft.com/en-us/library/aa238959(SQL.80).aspx (if you are using SQL Server 2000).

Event data file:
This is one way of submitting "raw" data to your SQL NS app. Yes, you need to copy the new file (with new raw data) into the specified directory every time you have collected new data and want it processed.
There is another way of submitting raw data to your NS app: using a built-in SQL Event Provider. Basically, it means inserting data into a SQL Server table, and then SQL NS takes care of the rest: processing the new data, matching it against subscriptions, etc.
Also, you can create your own custom event provider, but this task should come only after you have no problems with the "basic" stuff...

So, briefly, I would recommend that you start with the tutorial, and get a good book.

|||

Sorry, I put it a wrong way: of course, the differences between NS 2.0 (for SQL Server 2000) and NS for SQL Server 2005 are NOT negligible.

What I was trying to say is: if you know NS for SQL Server 2000, it will take you only a couple of hours to learn what's new in NS 2005.

On the other hand, if you don't care about SQL Server 2000 and need NS 2005, get Shyam Pather's book (on NS 2005).

...and let's hope that Joe Webb will write another edition of his excellent book, this time for SQL Server 2005 (or, 2008).

|||

thanks for your post...

but I got 2 questions:

first : what should really be the values of nsServer,serviceUserName,servicePassword ?

because to be honest I've put for nsServer(the name of the server in SQL Managment studio)

& for serviceUserName,servicePassword ( the username & password that I login with it to windows)

Iam sure there is a problem here cause everyime I try to start the Ns from managment studio I get an error?

second: what I understood from your post is that the way I am using the C# classes does not let me or don't let me need the XML files ....but the sample Iam trying to follow infact uses it

http://en.csharp-online.net/Notification_Services%E2%80%94Creating_a_Notification_Services_Application_and_Service_2

so Iam kind of confuessd ....can you please clear this point to me?

No comments:

Post a Comment