2
I have a question regarding receiving SQL data in a Javascript array. I have the login information and everything, related to the server, but the issue is not the connection, is to save the data in an array. Example: nameArray[username, email] (how to require this SQL info?)
app.get('/',(req, res) => {res.render('pages/home')})
function loginClient(){
var conn = new sql.Connection(dbConfig);
conn.connect().then(function(){
var req = new sql.Request(conn);
req.query("SELECT [CodCliSite],[RazaoSocial],[Email],[Pass] FROM [SITE].
[dbo].[Clientes]").then(function(recordset){
res.contentType('application/json');
res.send(JSON.stringify(recordset));
console.log(recordset);
conn.close();
}).catch(function(err){
console.log(err);
conn.close();
});
}).catch(function(err){
console.log(err);
});
}
return loginClient();
creates a javascript object and places the values that this array input, is difficult at the time of assignment?
– Julio Henrique
Exactly!!! I really need some help when it comes to the assignment.
– Leonardo Matiazzo
you can get the variables in your html or . jsp?
– Julio Henrique
yes, you can. But the question is assigning SQL values for verification.
– Leonardo Matiazzo
Example: in the form has two fields, name and email. but I need SQL NAME and EMAIL variables to be captured in an array, for verification...
– Leonardo Matiazzo
Do not confuse Java with Javascript, this is the same as confusing dog with hot dog. They are two totally different languages. I even closed your question as a duplicate because in Java, we already have some answers to that. But your question is actually about Javascript. I’ve reopened it. This disorder would have been avoided if you hadn’t made this mess.
– Victor Stafusa
Thank you for reopening the question.
– Leonardo Matiazzo
@Victorstafusa, would you tell me any solution?
– Leonardo Matiazzo
@Leonardomatiazzo No, I don’t know enough Javascript SQL for that. You’re using Node.js?
– Victor Stafusa
@Victorstafusa, yes I am! The problem is realizing this connection...
– Leonardo Matiazzo