Public Shared Function GetSetting(ByVal Key As string, ByVal SiteURL As String, Byval ListName as String)
Using oSite As SPSite = New SPSite(SiteURL)
Using oWeb As SPWeb = oSite.OpenWeb()
Dim oQry As SPQuery = New SPQuery
oQry.Query = "<Where><Eq><FieldRef Name='Title'/><Value Type='Text'>" & Key & "</Value></Eq></Where>"
oQry.RowLimit = 100
Dim oList As SPList = oWeb.Lists(ListName)
Dim oItems As SPListItemCollection = oList.GetItems(oQry)
If oItems IsNot Nothing AndAlso oItems.Count = 1 Then
Dim sValue As String = System.Web.HttpUtility.HtmlDecode(oItems(0).GetFormattedValue("Value"))
Return sValue
Else
Throw New Exception(String.Format("A value for key:{0} was not found in the {1} List on site:{2}", Key,ListName, SiteURL))
End If
End Using
End Using
End Function