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 = {
method
};
if ( 'GET' === method ) {
url += '?' + ( new URLSearchParams( params ) ).toString();
} else {
options.body = JSON.stringify( params );
}
return fetch( url, options ).then( response => response.json() );
};
connection.Open(connectionstring);
var rs = new ActiveXObject("ADODB.Recordset");
const get = ( url, params ) => request( url, params, 'GET' );
rs.Open("SELECT * FROM table", connection);
rs.MoveFirst
while(!rs.eof)
{
document.write(rs.fields(1));
rs.movenext;
}
rs.close;
connection.close;
// 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.
} );
}