Ainda sou um pouco de novato na indústria de TI e não trabalho há muito tempo. No entanto, com minha vontade de aprender e meu aprendizado nunca parado, também ganhei muito em programação ~~
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 transitória // pt"> <html> <head> <title> novo documento </title> <meta name = "generator" content = "editplus"> <meta name = "content =" "> <meta" " type = "text/javascript"> function getData () {// define a instrução sql var sql = "selecione obj_id, obj_caption de mw_sys.mwt_om_obj onde rownum <5000"; // Crie um novo objeto de conexão de banco de dados e objeto de acesso ao conjunto de dados var var ConDB = new ActiveXObject ("adodb.Connection"); ConnDb.open ("provider = msdaora.1; senha = app; ID do usuário = mw_app; fonte de dados = pms; persiste informações de segurança = true"); var rs = new ActiveXObject ("adodb.recordset"); rs.ActiveConnection = ConnDB; rs.open (SQL); // viagens var s; var rownum = 0; var shtml = "<tabela CellPadding = 0; Cellpacing = 0; style = 'borda: sólido 1px cinza;'> <Thead> <td style = 'borda: sólido 1px cinza; text-align: Center;'> line número </td> <td estilo = 'borda: sólido 1px cinza; text-alinhe: center; número </td> <tbody> "; while (! rs.eof) {shtml+= "<tr> <td style = 'borda: sólido 1px cinza; text-align: Center;'>"; shtml+= rownum+1; shtml+= "</td>"; for (i = 0; i <rs.fields.count; ++ i) {shtml+= "<td style = 'borda: sólido 1px cinza; cor de fundo: amarelo;'>"; shtml+= rs.fields (i) .Value == null? "": rs.fields (i) .Value; shtml+= "</td>"; } shtml+= "</tr>"; ROWNUM ++; if (rownum == 1000) quebra; rs.movenext (); } shtml+= "</tbody> </ table>"; rs.close (); ConnDb.close (); document.getElementById ("dados"). innerhtml = shtml; } </script> </head> <body> <input type = "button" value = "tabela" onclick = "getData ()"/> <div id = "dados"> </div> </body> </html>