Link to home
Create AccountLog in
Avatar of PowerEdgeTech
PowerEdgeTechFlag for United States of America

asked on

Database Access from HTML Page

Is it possible to access, read, and display a single database value from inside of a standard XHTML page without changing the page extension from .HTML?  I know I could change it to ASP, ASPX, PHP, etc. and do it that way, but I would like to preserve the existing URL structure.  I realize I could also do it in an IFRAME, but the value being returned may be differing sizes.  What are my options experts?

Thanks!
Avatar of Michael Knight
Michael Knight
Flag of United States of America image

...don't do it... you can pull that off with Javascript like so (Assuming MSSQL):

 
var connection = new ActiveXObject("ADODB.Connection") ;

var connectionstring="Data Source=<server>;Initial Catalog=<catalog>;User ID=<user>;Password=<password>;Provider=SQLOLEDB";

connection.Open(connectionstring);
var rs = new ActiveXObject("ADODB.Recordset");

rs.Open("SELECT * FROM table", connection);
rs.MoveFirst
while(!rs.eof)
{
   document.write(rs.fields(1));
   rs.movenext;
}

rs.close;
connection.close;

Open in new window


but don't do it. You need a preprocessor (ASP, PHP, etc.) for security and stability... plus not everyone has JS enabled. Nevermind the page has the connection info in plain text FFS
Avatar of PowerEdgeTech

ASKER

Thanks.  So, while it is technically "possible", it is so impractical that we could say "no, this can't be done"?  Is this the answer you're giving me?
ASKER CERTIFIED SOLUTION
Avatar of Dave Baldwin
Dave Baldwin
Flag of United States of America image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
Yes PowerEdgeTech, anything is technically "possible" but as far as whomever is asking you to do this is concerned the answer is no. If that person is you, then no.

If your only concern is updating links "URL Structure", you can batch replace those links pretty painlessly in Dreamweaver or Useful File Utilities and rest easy at night knowing your data isn't out there in the open.

did I say "Don't do it?"     ;)
Sorry for the delay ... crash course in AJAX (of course I had to search way beyond w3schools to get it to work) and we're in business.

mk ... while I appreciate your taking the time to show me how not to do it, I would (as you would) never consider that a real option.  I know I can change the extensions easy enough, but it is not a matter of "easy" ... the job requirement was to not change them (unless absolutely necessary).  AJAX is the answer to my question.