I'm creating a desktop application that talks to SQL Server for MAC users using Node.JS.
Is it possible in Node.JS to take the input from the user and display the data from SQL server based on user input?
For example, in the code below, can I put an input box onload
and allow user to input customercode
and display InvoiceNumber
and customername
.
Also, will I be able to run the below code on MAC?
@Serger B,
I followed the link you suggested and was successfully able to connect to SQL Server. How can I add a user prompt to enter the customerCode for the below code? Also, it would be great is someone could help me running the script from the browser.
var sql = require('mssql');
var config = {
user: 'temp',
password: 'test123',
server: 'laptop\\localDB', // You can use 'localhost\\instance' to connect to named instance
database: 'AVTemp01',
}
var connection = new sql.Connection(config, function(err) {
// ... error checks
// Query
var request = new sql.Request(connection); // or: var request = connection.request();
request.query('select top 5 companycode from invoiceheader', function(err, recordset) {
// ... error checks
console.dir(recordset);
});
// Stored Procedure
var request = new sql.Request(connection);
request.input('input_parameter', sql.Int, 10);
request.output('output_parameter', sql.VarChar(50));
request.execute('procedure_name', function(err, recordsets, returnValue) {
// ... error checks
console.dir(recordsets);
});
});
You should try this module to access the SQL server: https://www.npmjs.org/package/mssql We use it successfully in our projects. The quick example on the project homepage just shows it all.
And I don't see anything preventing you to do it on Mac.