<% ' Constants ripped from adovbs.inc: Const adOpenStatic = 3 Const adLockReadOnly = 1 Const adCmdText = &H0001 ' Our own constants: Const PAGE_SIZE = 5 ' The size of our pages. ' Declare our variables... always good practice! Dim strURL ' The URL of this page so the form will work ' no matter what this file is named. Dim cnnSearch ' ADO connection Dim rstSearch ' ADO recordset Dim strDBPath ' path to our Access database (*.mdb) file Dim strSQL ' The SQL Query we build on the fly Dim strSearch ' The text being looked for Dim iPageCurrent ' The page we're currently on Dim iPageCount ' Number of pages of records Dim iRecordCount ' Count of the records returned Dim I ' Standard looping variable ' Retreive the URL of this page from Server Variables strURL = Request.ServerVariables("URL") ' Retreive the term being searched for. I'm doing it on ' the QS since that allows people to bookmark results. ' You could just as easily have used the form collection. strSearch = Request.QueryString("search") strSearch = Replace(strSearch, "'", "''") ' Retrieve page to show or default to the first If Request.QueryString("page") = "" Then iPageCurrent = 1 Else iPageCurrent = CInt(Request.QueryString("page")) End If %> Nairobi City Council Official Website
Home About Nairobi City Hall News & Events Photo Gallery Contact Us DECENTRALIZATION
Online Services
Maps
Business
Security
Tenders
Projects

Click to read on the city council's decentralization program

<% If strSearch <> "" Then ' MapPath of virtual database file path to a physical path. ' If you want you could hard code a physical path here. strDBPath = Server.MapPath("data/ncc1.mdb") ' Create an ADO Connection to connect to the sample database. ' We're using OLE DB but you could just as easily use ODBC or a DSN. Set cnnSearch = Server.CreateObject("ADODB.Connection") ' This line is for the Access sample database: cnnSearch.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strDBPath & ";" ' Build our query based on the input. strSQL = "SELECT name, URL, title, thumb_URL, text " _ & "FROM photo_gallery " _ & "WHERE name LIKE '%" & Replace(strSearch, "'", "''") & "%' " _ '& "OR first_name LIKE '%" & Replace(strSearch, "'", "''") & "%' " _ '& "SORT BY main_date DESC; " _ ' Execute our query using the connection object. It automatically ' creates and returns a recordset which we store in our variable. Set rstSearch = Server.CreateObject("ADODB.Recordset") rstSearch.PageSize = PAGE_SIZE rstSearch.CacheSize = PAGE_SIZE ' Open our recordset rstSearch.Open strSQL, cnnSearch, adOpenStatic, adLockReadOnly, adCmdText ' Get a count of the number of records and pages ' for use in building the header and footer text. iRecordCount = rstSearch.RecordCount iPageCount = rstSearch.PageCount If iRecordCount = 0 Then ' Display no records error. %> <% Else ' Move to the page we need to show. rstSearch.AbsolutePage = iPageCurrent ' Show a quick status line letting people know where they are: %>
Disclaimer
The information displayed herein is provided in good faith, but we make no guarantees about the completeness, accuracy, timeliness, availability, accessibility, merchantability, or fitness for any particular purpose of any of the information. The City Council Of Nairobi is not responsible for any errors or omissions, which may occur in the information provided.
Any reference made by The City Council Of Nairobi in this web site to any company or any other entity, or to their services or products, is not an endorsement nor should it imply any such endorsement of the quality or fitness of purpose of that company or entity, or its services or products.
The City Council Of Nairobi disclaims all liability and responsibility for any loss, damage, or inconvenience whatsoever or howsoever suffered, directly or indirectly by any person as a result of their use of this web site and of any information and contact details supplied.
Any person proposing to use or rely on any of the contact details should first satisfy themselves of the completeness and accuracy of those contact details and any other information displayed with or in relation to them on this web site.
Any access of this web site by the user is entirely at the user's own risk and The City Council Of Nairobi shall not be responsible for the propagation of computer worms or viruses transmitted from the site. By accessing this web site you agree with these conditions and agree to hold harmless the operators and maintainers of the web site and their agents and partners.
Info center
Tourism
Hotels
Attractions
Sight Seeing
Going Out
Restaurants
Shopping
Entertainment
 
Information
Travel
Transport
Maps
Recreation
Police Stations
Education
Business
Conventions
Exhibitions
Conferences
 
 
Site Developed and Maintained by Midafrica Technologies