%
' Selected constants from adovbs.inc
Const adOpenStatic = 3
Const adLockPessimistic = 2
Dim MyDate
Dim MyDay
Dim MyMonth
Dim MyMonthName
Dim MyYear
Dim cnnExcel
Dim rstExcel
Dim I
Dim iCols
Dim sexvar
Dim string
Dim code
code=request.form("suite")
string="SELECT * FROM TestData where Suite='" & code & "';"
' This is all standard ADO except for the connection string.
' You can also use a DSN instead, but so it'll run out of the
' box on your machine I'm using the string instead.
Set cnnExcel = Server.CreateObject("ADODB.Connection")
cnnExcel.Open "DBQ=" & Server.MapPath("../spreadsheets/titles_2.xls") & ";" & _
"DRIVER={Microsoft Excel Driver (*.xls)};"
' Same as any other data source.
' FYI: TestData is my named range in the Excel file
Set rstExcel = Server.CreateObject("ADODB.Recordset")
rstExcel.Open string, cnnExcel, _
adOpenStatic, adLockPessimistic
' Get a count of the fields and subtract one since we start
' counting from 0.
iCols = rstExcel.Fields.Count
ON ERROR RESUME NEXT
IF rstExcel.EOF THEN
Response.Write "There are no entries for this suite at this time.
If you require urgent information, please contact us here.
"
End If
%>
| " Response.Write rstExcel.Fields.Item(I).Name Response.Write " | " & vbCrLf Next 'I %> <% rstExcel.MoveFirst ' Loop through the data rows showing data in an HTML table. Do While Not rstExcel.EOF Response.Write "||||
|---|---|---|---|---|
| " MyDate = (rstExcel.Fields.Item(I).Value) MyMonth = Month(MyDate) MyMonthName = MonthName(MyMonth,true) MyDay = Day(MyDate) MyYear = Year(MyDate) Response.Write (MyDay & "-" & MyMonthName & "-" & MyYear) Response.Write " | " & vbCrLf End If ElseIf I = 3 then Response.Write "" Response.Write (rstExcel.Fields.Item(I).Value) Response.Write " | " & vbCrLf ElseIf I = 0 then Response.Write "" Response.Write (rstExcel.Fields.Item(I).Value) Response.Write " | " & vbCrLf ElseIf I = 1 then Response.Write "" Response.Write ("" & (rstExcel.Fields.Item(I).Value) & "") Response.Write " | " & vbCrLf Else Response.Write "" Response.Write (rstExcel.Fields.Item(I).Value) Response.Write " | " & vbCrLf End if ' Next 'I Response.Write "