Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 368
  • Last Modified:

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!
0
PowerEdgeTech
Asked:
PowerEdgeTech
  • 2
  • 2
1 Solution
 
Michael KnightCommented:
...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
0
 
PowerEdgeTechIT ConsultantAuthor Commented:
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?
0
 
Dave BaldwinFixer of ProblemsCommented:
No, it is so insecure that it Shouldn't be done.  It would give everyone access to your database.

You can use AJAX to get info from an ASP or PHP page and display it in an HTML page.  Here's some info on AJAX http://www.w3schools.com/ajax/default.asp
0
 
Michael KnightCommented:
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?"     ;)
0
 
PowerEdgeTechIT ConsultantAuthor Commented:
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.
0

Featured Post

Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now