Showing posts with label quotcannot. Show all posts
Showing posts with label quotcannot. Show all posts

Wednesday, March 7, 2012

Problem with Dependencies and the error "Cannot find the remote service"

Hello all.

We are a small taskforce currently working on a system of which utilizes the SQL notification service. For this we are using dependencies provided by SqlDependency. The dependency is set up as follows:

//Where dbo.MTable is the table and guid is the unique key of the records. We //want to listen to individual records and not the entire table

SqlCommand listenCommand = new SqlCommand( "SELECT ID FROM dbo.MTable WHERE ID = " + "@.guid", connection );

listenCommand.Parameters.AddWithValue( "@.guid", guid );

depend = new SqlDependency( listenCommand, null, 0 );

depend.OnChange += onChangeEventHandler;

If you’re not so bold as to look in the database server log, and you do not care about log growth of cataclysmic proportions which will inevitably crash the server, it will work fine. The problem is, as hinted above, that the server log is filled with error messages.

Error Code: 8490

Description: “Cannot find the remote service : because it does not exist.”

Here is an example of before mentioned messages:

The query notification dialog on conversation handle '{F53C37DE-E66A-DA11-90A1-00105AC00126}.' closed due to the following error: '<?xml version="1.0"?><Error xmlns="http://schemas.microsoft.com/SQL/ServiceBroker/Error"><Code>-8490</Code><Description>Cannot find the remote service &apos;SqlQueryNotificationService-cc3933a7-f97f-45b4-822f-f326f9f6e373&apos; because it does not exist.</Description></Error>'.

We have realized that listening on an entire table does not provoke this error. Furthermore, experiments have shown that the error only appears after we have shut down our system.

On shutdown, we call the following method:

SqlDependency.Stop( connection.ConnectionString );

This seems to stop the database from sending out notifications when we listen to an entire table, but not when we listen to individual records. Are we using the service in an incorrect manner or is there an error in the Stop method?

We have discovered a hotfix, but it is not exactly a beautiful solution:

SqlDependency.Start( connection.ConnectionString );

SqlCommand listenCommand = new SqlCommand( "SELECT * FROM MTable", connection );

depend = new SqlDependency( listenCommand );

SqlDependency.Stop( m_ConnectionString );

We have found that by ‘restarting’ the SqlDependency and giving it a new dependency where it listens to the entire table and THEN stopping it, the error does not appear. Our theory is that the new start and dependency overwrites the old ones.

I believe you have posted this issue to the wrong forum. SqlDependency is not a part of the Notification Services, despite the similar name. You might try a SQL 2005 forum instead.

Monday, February 20, 2012

Problem with datatypes...

Dear Friends,

I have a problem with datatypes....

The error is "Cannot convert between unicode and non-unicode..."

The column in source is nvarchar(32) and in the destination is varchar(32)... ok...

But in the DataReader Source in the SQLCommand I've converted the column into varchar(32) with

convert(varchar(32), Equities.Equities_Name) as CL_FOLDER_ID

Do you have any tip?

Thanks!

Look at the actual output column for the Source, and you will see that that is DT_WSTR, the unicode string type in SSIS. The DR source does not support non-unicode strings, everything becomes a .Net string in the ADO.Net provider world, and and then SSIS will always treat these as DT_WSTR. If you used the OLE-DB Source through, you get support for both DT_STR and DT_WSTR, mapped from nvarchar and varchar respectively.

So in summary since your source will always give you DT_WSTR, you will need to use a conversion transform inside the pipeline, see Derived Column or Data Conversion, either will do.

|||

Darren,

I used the conversion, but I i tryied to use in SQL command, but if it's not possible, OK... I will use the conversion transform...

Thanks!!