JavaScript Operations Oracle Database sample _javascript Tips

Source: Internet
Author: User

I am still a small rookie of IT industry, to participate in the work time is not long, but with their own a studious heart still have their own learning footsteps never stop, their programming is also a very fruitful ~ ~

It has always been assumed that JavaScript wants to interact with the database through Ajax to invoke server-side code (C # or Java), but only recently did it find that JavaScript can interact directly with the database ... Here is a simple data from the database to load to the interface of a small example (of JS operation data on the knowledge of everyone if there is any good advice we hope you can stay, we learn from each other, common progress) ~ ~

<! DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 transitional//en" > <HTML> <HEAD> <TITLE> New Document ;/title> <meta name= "generator" content= "EditPlus" > <meta name= "Author" content= "" > <meta NAME= "Keyw Ords "Content=" "> <meta name=" Description "content=" "> <script type=" text/javascript "> Function getData
    () {//define SQL statement var sql = "Select Obj_id,obj_caption from Mw_sys.mwt_om_obj where rownum<5000"; New database Connection object and DataSet Access object var conndb = new ActiveXObject ("ADODB.
    Connection "); Conndb.open ("Provider=MSDAORA.1; Password=app; User Id=mw_app;data Source=pms;
    Persist security Info=true "); var rs = new ActiveXObject ("ADODB.
    Recordset "); Rs.
    ActiveConnection = conndb; Rs.
    Open (SQL);
    Traverse var S;
    var rownum=0; var shtml= "<table cellpadding=0; cellspacing=0; Style= ' border:solid 1px gray; ' &GT;&LT;THEAD&GT;&LT;TD style= ' border:solid 1px gray; Text-align:center; ' > Line number </td><td style= ' bOrder:solid 1px Gray; Text-align:center; ' > Job Text ID number </td><td style= ' border:solid 1px gray; '
    > Professional number </td><tbody> "; while (!rs. EOF) {shtml+= "<tr><td style= ' border:solid 1px Gray; text-align:center; '
      > ";
      shtml+=rownum+1;
      shtml+= "</td>"; for (i = 0;i<rs. Fields.count;++i) {shtml+= "<td style= ' border:solid 1px Gray; background-color:yellow; '
        > "; Shtml+=rs. Fields (i). Value==null? " ": Rs.
        Fields (i). value;
      shtml+= "</td>";
      } shtml+= "</tr>";
      rownum++;
      if (rownum==1000) break; Rs.
    MoveNext ();
    } shtml+= "</tbody></table>";
    Rs.close ();
    Conndb.close ();
  document.getElementById ("Data"). innerhtml=shtml; } </script> </HEAD> <BODY> <input type= "button" value= "Table" onclick= "GetData ()"/> <d IV id= "Data" > </div> </BODY> </HTML>

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.