` Getting data out of TPS using ASP and ODBC (Brian Staff) - Icetips Article
Icetips - Templates, Tools & Utilities for Clarion Developers

Templates, Tools and Utilities
for Clarion Developers

Icetips Article

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 21, 2024, 3:41 am
This article has been viewed 35432 times.
Google search has resulted in 1356 hits on this article since January 25, 2004.



Back to article list   Search Articles   Add Comment   Printer friendly

Login

User Name:

Password: