Showing posts with label encountered. Show all posts
Showing posts with label encountered. Show all posts

Saturday, February 25, 2012

Query Notifications/ Service Broker problem

Hey , I encountered a problem using SqlDependency and notification services.

I’ve created a database with tools from c# Express 2005 and attached it to the sql server express 2005. And it turned out that ‘dependency_OnChange’ in my application is triggered each time I execute the command.ExecuteReader(); and it shouldn’t, because the command is just the select statement of columns and rows for which I wait to be modified.

SqlDependency dependency = new SqlDependency(command);

dependency.OnChange += new OnChangeEventHandler(dependency_OnChange);

command.ExecuteReader();//when the program gets here dependency_OnChange is called

So I Used the example from here :

http://msdn2.microsoft.com/en-us/library/a52dhwx7.aspx

and with AdventureWorks it behaves as it should , but when I change the connection string and select statement in the example to work with MyDatabase, the problem appears again.

So there is something wrong with MyDatabase ?

The select statement I used was “select Name, Pass from Users where Name like ‘L%’”;

So theoretically this should work but it does not and I end up in an infinite loop with

dependency_OnChange called cyclically …

I’d be grateful for any advice !

What are the dependency_OnChange paramater values passed in when the callback is notified?

I suspect the SqlNotificationEventArgs argument has a value of 'Subscribe' for the notification type, indicating an error in setting up the notification. If the statement you included is the exact statement you'd tried, then the problem is that your query is not respecting the Query Notifications restrictions. The query select Name, Pass from Users where Name like ‘L%’ is not properly schema bound, the Users table name should be bound with a schema name (e.g. dbo.Users).

HTH,
~ Remus

Query Notification not fire all subscriptions...

Hello all,

We have encountered a weird problem; we have an application that registers to several queries for notification.

For several weeks everything worked fine, any change to any query result in the database triggered the notification event, but since yesterday the mystery began… since yesterday not all changes triggers events , changing one table raise the notification event, changing the other doesn’t , all seems fine in the database , the application reports that all queries were registered successfully , in the subscription view in the database we can see that all the queries that the application subscribed to are present…

What can be the problem? Is it something in the database? Can it be a problem in our application, please keep in mind that everything worked until yesterday…

Thanks,

Eden

Check sys.transmission_queue in the database where the events are registered. If it contains undelivered notifications, check the transmission_status column, it should tell you the reason why the messages cannot be delivered.|||

Thanks for your answer Remus

Unfortunately our Dba’s deleted the transmission queue, and now it’s all working again,

The Dba’s said that the transmission queue is getting very large (even millions of records) with the Conversing status.

Can the queue overflow be the problem?

Thanks

|||

No, that's not the problem. Queues don't 'overflow'. The transmission queue cannot be deleted, so the dba must had eaither terminated the dialogs with cleanup or started a new broker in the database.

If millions of conversation in 'Conversing' state accumulate, it means you notification are not being delivered. Again, the transmission_status of column will indicate the cause.

Query not returning all results

OK, interesting problem I haven't encountered before.
If I do the following query:
Select * from TableA where SequenceNo = 555 and Column = 6 and ClientNo = '123456'
I get 1 row (which is correct).
If I run the same query without the ClientNo specification, I get 4 results,
but Clientno 123456 isn't in the results.
If I run the same query, without the ClientNo specification, without the *
(i.e. manually listing each column), then I get 20 results, which is correct.
Why is this happening? Anyone know how to resolve this?
Manually listing each column is so not an option. Why isn't "Select * from
TableA where SequenceNo = 555 and Column = 6" to returning all 20 valid
results?
FYI: SequenceNo and Column are datatypes int, Clientno is varchar.
I've tried with and without single quotes, and also adding in "where
sequenceno is not null" kind of logic, too.
Argh!!!!!
--
Financial Systems Analyst
CCNA, MCSE, MCSA, MCDBANever mind!
forgot to check to Message tab (doh!), there was a Numeric Value Out Of
Range error.
So, anyone know how to resolve THAT little issue?!?
Thanks!|||Sounds like you've got data corruption or, at least, integrity issues.
Probably because of the use of SELECT * and such.
If you are explicit about everything you do, then there will never be a
question concerning what it is you want.
Leave everything to defaults and you will get ambiguity, which is that start
of corruption.
Sorry to disappoint you, but you need to fix your data or start being more
explicit.
You could try a TOP clause to find the row that is causing you grief and,
then, manually fix the data.
Sincerely,
Anthony Thomas
"Ysandre" <Ysandre@.discussions.microsoft.com> wrote in message
news:773DC2E5-81C5-4AEA-A563-020065BE8943@.microsoft.com...
Never mind!
forgot to check to Message tab (doh!), there was a Numeric Value Out Of
Range error.
So, anyone know how to resolve THAT little issue?!?
Thanks!

Query not returning all results

OK, interesting problem I haven't encountered before.
If I do the following query:
Select * from TableA where SequenceNo = 555 and Column = 6 and ClientNo =
'123456'
I get 1 row (which is correct).
If I run the same query without the ClientNo specification, I get 4 results,
but Clientno 123456 isn't in the results.
If I run the same query, without the ClientNo specification, without the *
(i.e. manually listing each column), then I get 20 results, which is correct
.
Why is this happening? Anyone know how to resolve this?
Manually listing each column is so not an option. Why isn't "Select * from
TableA where SequenceNo = 555 and Column = 6" to returning all 20 valid
results?
FYI: SequenceNo and Column are datatypes int, Clientno is varchar.
I've tried with and without single quotes, and also adding in "where
sequenceno is not null" kind of logic, too.
Argh!!!!!
Financial Systems Analyst
CCNA, MCSE, MCSA, MCDBANever mind!
forgot to check to Message tab (doh!), there was a Numeric Value Out Of
Range error.
So, anyone know how to resolve THAT little issue?!?
Thanks!|||Sounds like you've got data corruption or, at least, integrity issues.
Probably because of the use of SELECT * and such.
If you are explicit about everything you do, then there will never be a
question concerning what it is you want.
Leave everything to defaults and you will get ambiguity, which is that start
of corruption.
Sorry to disappoint you, but you need to fix your data or start being more
explicit.
You could try a TOP clause to find the row that is causing you grief and,
then, manually fix the data.
Sincerely,
Anthony Thomas
"Ysandre" <Ysandre@.discussions.microsoft.com> wrote in message
news:773DC2E5-81C5-4AEA-A563-020065BE8943@.microsoft.com...
Never mind!
forgot to check to Message tab (doh!), there was a Numeric Value Out Of
Range error.
So, anyone know how to resolve THAT little issue?!?
Thanks!

Query not returning all results

OK, interesting problem I haven't encountered before.
If I do the following query:
Select * from TableA where SequenceNo = 555 and Column = 6 and ClientNo =
'123456'
I get 1 row (which is correct).
If I run the same query without the ClientNo specification, I get 4 results,
but Clientno 123456 isn't in the results.
If I run the same query, without the ClientNo specification, without the *
(i.e. manually listing each column), then I get 20 results, which is correct.
Why is this happening? Anyone know how to resolve this?
Manually listing each column is so not an option. Why isn't "Select * from
TableA where SequenceNo = 555 and Column = 6" to returning all 20 valid
results?
FYI: SequenceNo and Column are datatypes int, Clientno is varchar.
I've tried with and without single quotes, and also adding in "where
sequenceno is not null" kind of logic, too.
Argh!!!!!
Financial Systems Analyst
CCNA, MCSE, MCSA, MCDBA
Never mind!
forgot to check to Message tab (doh!), there was a Numeric Value Out Of
Range error.
So, anyone know how to resolve THAT little issue?!?
Thanks!
|||Sounds like you've got data corruption or, at least, integrity issues.
Probably because of the use of SELECT * and such.
If you are explicit about everything you do, then there will never be a
question concerning what it is you want.
Leave everything to defaults and you will get ambiguity, which is that start
of corruption.
Sorry to disappoint you, but you need to fix your data or start being more
explicit.
You could try a TOP clause to find the row that is causing you grief and,
then, manually fix the data.
Sincerely,
Anthony Thomas

"Ysandre" <Ysandre@.discussions.microsoft.com> wrote in message
news:773DC2E5-81C5-4AEA-A563-020065BE8943@.microsoft.com...
Never mind!
forgot to check to Message tab (doh!), there was a Numeric Value Out Of
Range error.
So, anyone know how to resolve THAT little issue?!?
Thanks!