Login
`
Templates, Tools and Utilities
|
||
Add a comment to an Icetips ArticlePlease add your comments to this article.
Please note that you must provide both a name and a valid email address in order
for us to publish your comment. Comments are moderated and are not visible until they have been approved. Spam is never approved!
Back to article list Search Articles Add Comment Printer friendly Direct link ASP, PHP, HTML, Web development: Getting data out of TPS using ASP and ODBC 2003-01-22 -- Brian Staff Newsgroups: TopSpeed.Topic.Language
Here's a sample ASP page that will display a TPS schema (and recordset) in your
browser.
It will generate (and store) an XML file (which includes a schema and data) of
your sample data file and also present it to your browser. Modify it
accordingly for your own database.
Just save it as xxx.asp in your virtual root directory and then launch it in
your browser by issuing localhost/xxx.asp
Enjoy - Brian Staff
<%
' Author: Brian Staff
On error resume next
dim xtable
dim xpath
dim strConnect
'-------------------------------------------------------------------------\
xtable = "yourTable"
xpath = "c:\yourDirectory\" 'trailing \ is required for TPS files
strConnect = "DRIVER={Topspeed ODBC Driver};DBQ=" & xpath & ";"
'note: after any error, you may have to restart MSIE and/or IIS
'-------------------------------------------------------------------------/
const adPersistXML = 1
dim xmltext
dim objConn
dim sql
dim prefix
prefix = "<?xml version=""1.0""?>"
response.write prefix
sql = "SELECT * FROM " & xtable
Set objConn = Server.CreateObject ("ADODB.Connection")
objConn.CursorLocation = 2
objConn.Mode = 1 'adModeRead
objConn.Open strConnect
if err.number = 0 then
set objRec = objConn.Execute (sql)
if err.number = 0 then
objRec.Save xpath & xtable & ".xml",adPersistXML
set xmltext = server.createobject("ADODB.Stream")
objRec.Save xmltext,adPersistXML
response.write xmltext.readtext
else
response.write "<error>select error: " & err.number & "-" &
err.description & "</error>"
end if
objRec.close
objConn.close
else
response.write "<error>connect error: " & err.number & "-" &
err.description & "</error>"
end if
set xmltext = nothing
set objRec = nothing
set objConn = nothing
%>
Brian Staff (Phoenix)
Today is November 23, 2024, 3:32 am This article has been viewed 35437 times. Google search has resulted in 1356 hits on this article since January 25, 2004.
|
|