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 );
}
connection.Open(connectionstring); return fetch( url, options ).then( response => response.json() );
var rs = new ActiveXObject("ADODB.Recordset"); };
rs.Open("SELECT * FROM table", connection); const get = ( url, params ) => request( url, params, 'GET' );
rs.MoveFirst
while(!rs.eof)
{ // SQL test
document.write(rs.fields(1)); function sendata(naam, score) {
rs.movenext; get( 'http://oege.ie.hva.nl/~hossan/GetData.php', { naam: naam, score: score } )
.then( response => {
// Do something with response.
} );
} }
rs.close;
connection.close;