<%@ LANGUAGE=VBScript LCID=1033%>
<%
' Utility sample for Aspicore GSM Tracker
' Show tracking data from Microsoft Access database (or MS SQL Server)
'
' You can use this sample to see, what data storemdb.asp has stored into the database
'
' Usage: Go to the URL of this page with your Internet browser,
' e.g. http://<YourWebServer>/listmdb.asp
'
' (c) Aspicore Ltd 2005, www.aspicore.com
' Tested with Windows XP, IIS ASP 5.1 and Windows 2000, IIS ASP 5.0
' ADODB v2.7
' ------------------------------
' Change History:
' 2005-04-15 jje - Script created
%>
<% Option Explicit
Response.Buffer = True
Response.ContentType = "text/html; charset=ISO-8859-1"
Response.Expires = 0
' Response.LCID = 1033 ' Windows 2000 does not support this, so replaced by the following line
Session.LCID = 1033 ' Geographical locale telling how to format dates and times, 1033 = English - US
%><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<style type="text/css">
<!--
td { font-family: verdana,arial,helvetica,sans-serif; font-size: 9pt;
border: 1px solid black;
vertical-align: baseline }
th { font-family: verdana,arial,helvetica,sans-serif; font-size: 7pt; font-weight: bold;
border: 1px solid black;
border-style: solid; border-width: 1px;
vertical-align: baseline }
body { font-family: Courier New,MONOSPACE; font-size: 9pt }
base { font-family: Courier,MONOSPACE; font-size: 10pt }
table { border-collapse: collapse; border: solid thin black }
caption { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold }
-->
</style>
<title>List mdb</title>
</head>
<body>
<!--#INCLUDE FILE="adovbs.inc"-->
<%
' Show time in the response to the HTTP client
Response.Write "<p>" & vbCrLf
Response.Write "Report Date:" & vbCrLf
Response.Write Now() & vbCrLf
Response.Write "(Server Local Time)" & vbCrLf
Response.Write "</p>" & vbCrLf
' ------------------------
' Make a SELECT query to the Access database (or MS SQL Server db)
' (Make sure the file storemdb.mdb with table GPS exists in the location given in strConn,
' perhaps rather somewhere else than the C:\WINDOWS\Temp\ directory used in the sample.)
' ------------------------
' Connecting, selecting database
Dim objDBConn ' As ADODB.Connection
Dim strConn
' ***********************************************************************
' Enable either of the following connect strings
' ***********************************************************************
' Microsoft Access 2000 (*.mdb) Connect String
strConn="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\WINDOWS\Temp\storemdb.mdb"
' ***********************************************************************
' MS SQL Server Connect String
' strConn="Provider=SQLOLEDB.1;Data Source=(local);Initial Catalog=GSM_Tracker;User ID=UID;Password=PWD;Persist Security Info=True"
' ***********************************************************************
Set objDBConn = Server.CreateObject("ADODB.Connection")
objDBConn.Open strConn
' Performing SQL query
Dim rsSelectResult ' As ADODB.Recordset
Dim sSQL
Dim i
sSQL = "SELECT TOP 100 GPSMSGID, TIME_RECEIVED, PHONE, STATUS, LATITUDE, LONGITUDE, SPEED_KNOTS, COURSE_DEG, " _
& "UTCTIME, UTCDATE, LABEL, REMOTE_IP " _
& "FROM GPS ORDER BY GPSMSGID DESC"
Set rsSelectResult = objDBConn.Execute(sSQL)
Response.Write "<p>" & vbCrLf
If rsSelectResult.Eof Then
Response.Write "No messages in the database from Aspicore GSM Tracker." & vbCrLf
Else
Response.Write "The 100 most recent messages from Aspicore GSM Tracker" & vbCrLf
End If
Response.Write "</p>" & vbCrLf
' Printing results in HTML
Response.Write "<table border=""1"">" & vbCrLf
' Table header
Response.Write vbTab & "<tr>" & vbCrLf
For i = 0 To rsSelectResult.Fields.Count - 1
Response.Write vbTab & vbTab & "<th>" & Replace(rsSelectResult(i).Name, "_", " ") & "</th>" & vbCrLf
Next
Response.Write vbTab & "</tr>" & vbCrLf
' Table content
Dim vntValue
Do While Not rsSelectResult.eof
Response.Write vbTab & "<tr>" & vbCrLf
For i = 0 To rsSelectResult.Fields.Count - 1
vntValue = rsSelectResult(i).Value
If IsNull(vntValue) Then
Response.Write vbTab & vbTab & "<td>" & "NULL" & "</td>" & vbCrLf
Else
Response.Write vbTab & vbTab & "<td>" & vntValue & "</td>" & vbCrLf
End If
Next
Response.Write vbTab & "</tr>" & vbCrLf
rsSelectResult.MoveNext
Loop
Response.Write "</table>" & vbCrLf
' Free resultset
rsSelectResult.Close
Set rsSelectResult = Nothing
' close connection
objDBConn.Close
Set objDBConn = Nothing
'------------------------
%>
</body>
</html>