TransWikia.com

SQL Server update statement using .NET made function does not run

Geographic Information Systems Asked on January 28, 2021

In SQL Server I have a table called Track containing metadata of each track and a spatial representation of it: the field Geo, which is a LineString of the geography type.

In Visual Studio I developed a function MakeLineString that constructs those spatial representations based on GPS points in a table. The input for the function is the field TrackId of the table Track. I imported the function in SQL Server and it runs well in itself, for instance in:

DECLARE @Track geography;
SET @Track = dbo.MakeLineString(10)
SELECT @Track AS Shape, @Track.STNumPoints() as NumPoints;

Now I want to fill all fields Geo in the table Track with T-sql. In principle it’s easy, my code is:

update Track
set Geo = dbo.MakeLineString(TrackId)

However, it does not run.

The error message is:

Msg 6522, Level 16, State 1, Line 1
A .NET Framework error occurred during execution of user-defined routine or aggregate "MakeLineString": 
System.Runtime.InteropServices.COMException: The new transaction cannot be included in the list for the specified transaction coordinator.
System.Runtime.InteropServices.COMException: 
   At System.Data.Common.NativeMethods.ITransactionJoin.JoinTransaction(Object punkTransactionCoord, Int32 isoLevel, Int32 isoFlags, IntPtr pOtherOptions)
   At System.Data.OleDb.OleDbConnectionInternal.EnlistTransactionInternal(Transaction transaction)
   At System.Data.OleDb.OleDbConnection.Open()
   At MyClass.MakeLineString(SqlInt16 TrackId)

I have no idea what’s wrong.

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP