Advertisement
Guest User

Untitled

a guest
Sep 28th, 2016
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.51 KB | None | 0 0
  1. Public Shared Function getListPropertyListing(ByVal agencyCompanyRefOwner As String, ByVal psRefOwner As String, ByVal listingStatus As String) As DataTable
  2. Dim sqlCon As New SqlConnection(_constr)
  3. Dim sqlCmd As New SqlCommand
  4. Dim dt As New DataTable
  5.  
  6. Dim queryPsOwner As String = String.Empty
  7. If Trim(psRefOwner) <> "" Then
  8. queryPsOwner = " and l.psRefOwner = @psRefOwner "
  9. End If
  10.  
  11. sqlCon.Open()
  12. sqlCmd.Connection = sqlCon
  13. sqlCmd.CommandType = CommandType.Text
  14.  
  15. sqlCmd.CommandText = "select l.*, sb.subLocationName, ct.cityName, p.provinceName, lt.listingTypeName, pt.priceTypeName " + _
  16. "from " + _natapropertyDb + "..SEC_TR_listing l " + _
  17. " left join " + _natapropertyDb + "..SEC_LK_listingType lt on lt.listingTypeRef = l.listingTypeRef " + _
  18. " left join " + _natapropertyDb + "..SEC_LK_priceType pt on pt.priceType = l.priceType " + _
  19. " left join " + _natapropertyDb + "..LK_addrCountry c on c.countryCode = l.countryCode " + _
  20. " left join " + _natapropertyDb + "..LK_addrProvince p on p.countryCode = c.countryCode and p.provinceCode = l.provinceCode " + _
  21. " left join " + _natapropertyDb + "..LK_addrCity ct on ct.countryCode = c.countryCode and ct.provinceCode = p.provinceCode and ct.cityCode = l.cityCode " + _
  22. " left join " + _natapropertyDb + "..MS_subLocation sb on sb.countryCode = c.countryCode and sb.provinceCode = p.provinceCode and sb.cityCode = ct.cityCode and sb.subLocationRef = l.areaRef " + _
  23. " " + _
  24. " " + _
  25. " where l.listingStatus = @listingStatus and l.agencyCompanyRefOwner = @agencyCompanyRefOwner " + queryPsOwner
  26.  
  27. sqlCmd.Parameters.AddWithValue("@agencyCompanyRefOwner", agencyCompanyRefOwner)
  28. sqlCmd.Parameters.AddWithValue("@listingStatus", listingStatus)
  29. If Trim(queryPsOwner) <> "" Then
  30. sqlCmd.Parameters.AddWithValue("@psRefOwner", psRefOwner)
  31. End If
  32.  
  33. Dim sqlDa As New SqlDataAdapter(sqlCmd)
  34.  
  35. sqlDa.Fill(dt)
  36.  
  37. sqlCmd = Nothing
  38. sqlCon.Close()
  39.  
  40. Return dt
  41. End Function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement