'################################################################
'# This Funtion returns string array of road segment that
'# matchs Street Name, Type and Location City Zip and with range
'################################################################
_
Public Function GetArray_StreetSegment(ByVal strHnum As String, ByVal strPreDir As String, ByVal strName As String, ByVal strType As String, ByVal strcity As String, ByVal strzip As String) As String()
Dim RetVal(10) As String
Dim sqlCommand As String
Dim strSQLcommand As String
'-- Build the SQL command'
strSQLcommand = "Select OBJECTID, L_F_ADD,L_T_ADD, R_F_ADD, R_T_ADD, predir, stname, sttype, locationcity, zip from " & MyTable & " Where (("
If strPreDir = "" Then
strSQLcommand = strSQLcommand & "(predir = '' or predir is null)"
Else
strSQLcommand = strSQLcommand & "predir ='" & strPreDir & "'"
End If
strSQLcommand = strSQLcommand & " And StName ='" & strName & "'"
If strType = "" Then
strSQLcommand = strSQLcommand & " And (stType ='' or stType is null)"
Else
strSQLcommand = strSQLcommand & " And sttype ='" & strType & "'"
End If
strSQLcommand = strSQLcommand & " And LocationCity ='" & strcity & "'"
strSQLcommand = strSQLcommand & " And Zip ='" & strzip & "') "
strSQLcommand = strSQLcommand & " And (((L_F_ADD >=" & strHnum & " AND L_T_ADD <=" & strHnum & ")" & _
" Or (L_F_ADD <=" & strHnum & " AND L_T_ADD >=" & strHnum & ")) Or " & _
" ((R_F_ADD >= " & strHnum & " and R_T_ADD <= " & strHnum & ") Or " & _
" (R_F_ADD <= " & strHnum & " and R_T_ADD >= " & strHnum & "))))"
sqlCommand = strSQLcommand
' The data referenced is accessed through a MultiVersioned View (ESRI SDE terminology)
Dim VersionCommand1 As New SqlCommand("sde.set_current_version", connection)
VersionCommand1.CommandType = CommandType.StoredProcedure
VersionCommand1.Parameters.Add("@version_name", NVarChar, 25)
VersionCommand1.Parameters("@version_name").Value = MyVersion
connection.Open()
VersionCommand1.ExecuteNonQuery()
Dim adapter As SqlDataAdapter = New SqlDataAdapter(sqlCommand, connection)
Dim custDS As DataSet = New DataSet()
adapter.MissingSchemaAction = MissingSchemaAction.AddWithKey
adapter.Fill(custDS, MyTable)
'-- Should only be one record that matches if any so only look at 0
If custDS.Tables(0).Rows.Count > 0 Then
RetVal(0) = custDS.Tables(0).Rows(0).Item(0).ToString
RetVal(1) = custDS.Tables(0).Rows(0).Item(1).ToString
RetVal(2) = custDS.Tables(0).Rows(0).Item(2).ToString
RetVal(3) = custDS.Tables(0).Rows(0).Item(3).ToString
RetVal(4) = custDS.Tables(0).Rows(0).Item(4).ToString
RetVal(5) = custDS.Tables(0).Rows(0).Item(5).ToString
RetVal(6) = custDS.Tables(0).Rows(0).Item(6).ToString
RetVal(7) = custDS.Tables(0).Rows(0).Item(7).ToString
RetVal(8) = custDS.Tables(0).Rows(0).Item(8).ToString
RetVal(9) = custDS.Tables(0).Rows(0).Item(9).ToString
Else
RetVal(0) = "False"
End If
Return RetVal
End Function
|