added test to send data to database

This commit is contained in:
sam
2023-12-15 12:09:44 +01:00
parent 4c595e63d7
commit d398712afe

View File

@@ -1,17 +1,24 @@
var connection = new ActiveXObject("ADODB.Connection") ;
var connectionstring="Data Source=<server>;Initial Catalog=<catalog>;User ID=<user>;Password=<password>;Provider=SQLOLEDB"; const request = ( url, params = {}, method = 'GET' ) => {
let options = {
connection.Open(connectionstring); method
var rs = new ActiveXObject("ADODB.Recordset"); };
if ( 'GET' === method ) {
rs.Open("SELECT * FROM table", connection); url += '?' + ( new URLSearchParams( params ) ).toString();
rs.MoveFirst } else {
while(!rs.eof) options.body = JSON.stringify( params );
{
document.write(rs.fields(1));
rs.movenext;
} }
rs.close; return fetch( url, options ).then( response => response.json() );
connection.close; };
const get = ( url, params ) => request( url, params, 'GET' );
// SQL test
function sendata(naam, score) {
get( 'http://oege.ie.hva.nl/~hossan/GetData.php', { naam: naam, score: score } )
.then( response => {
// Do something with response.
} );
}