I am still a little novices in the IT industry and have not been working for a long time. However, with my eagerness to learn and my never-stop learning, I have also gained a lot in programming~~
I have always thought that JavaScript must use AJAX to call server-side code (C# or JAVA) to interact with the database, but recently I found that JavaScript can interact directly with the database... Below is a simple example of how to retrieve data from the database and load it into the interface (if you have any good suggestions on JS operation data, I hope you can stay, we will learn from each other and make progress together) ~~
<!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="Keywords" 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"; //Create a 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); //Travel var s; var rownum=0; var shtml="<table cellpadding=0; cellpacing=0; style='border:solid 1px gray;'><thead><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()"/> <div id="data"> </div> </BODY></HTML>