2012-08-23 34 views
3

這可能完全脫離基礎 - 但出於某種原因,我無法在SQL CLR函數(VB.NET)中聲明SqlGeography類型的變量。以下狀態表明SqlGeography沒有在第3行定義 - 很確定我需要導入一些東西 - 但找不到它。SQL CLR地理類型

哦是的 - 使用SSDT。

任何幫助表示讚賞。

Public Shared Sub usp_routing_dijkstra(node_1 As SqlGuid, node_2 As SqlGuid) 

    Dim StartGeo As SqlGeography 

    Using connection As New SqlConnection("context connection=true") 
     connection.Open() 

     Using command As New SqlCommand("select [geo] from [nodes] where [sys_id] = @id", connection) 
      Dim param As New SqlParameter("@id", SqlDbType.UniqueIdentifier) 
      param.Value = node_1 
      command.Parameters.Add(param) 
      Dim StartNode As Object 
      StartNode = command.ExecuteScalar() 
      If StartNode IsNot Nothing Then 

      End If 
     End Using 

    End Using 

End Sub 
+1

您是否有對Microsoft.SqlServer.Types的引用? – mfussenegger

+0

是的 - 對不起,我花了這麼長的時間來回答 - 我一直在我的脖子上:) – randmatt

回答

0

嘗試在項目中添加對Microsoft.SqlServer.Types的引用。在我的情況下,它位於C:\ Program Files文件(x86)\ Microsoft SQL Server \ 110 \ SDK \ Assemblies \ Microsoft.SqlServer.Types.dll。

然後,確保您在您的.vb文件的頂部以下Imports: 進口Microsoft.SqlServer 進口Microsoft.SqlServer.Types

之後,你應該能夠聲明的變量輸入SqlGeography。