added test to send data to database
This commit is contained in:
@@ -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.
|
||||
} );
|
||||
}
|
Reference in New Issue
Block a user