Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

370
Views
RequestError: Validation failed for parameter 'request_UserID'. Cannot read property 'validate' of undefined

Tyring to connect and Select record from MSSQL using NodeJS and tedious

Here is my code

connection.on("connect", function (err) {

    sqlCommand = new Request(
        "SELECT * FROM video.videoView WHERE Id = @Id AND CONVERT(VARCHAR(MAX), request_userID) = @request_UserID",
        function (err) {
            if (err) {
                console.log(err);
            }
        }
    );
    sqlCommand.addParameter("Id", TYPES.UniqueIdentifier, data.vid);

    sqlCommand.addParameter(
        "request_UserID",
        TYPES.VARCHAR,
        data.email_address
    );

    sqlCommand.on("row", function (columns) {
        columns.forEach(function (column) {
        });
    });

    sqlCommand.on("requestCompleted", function (rowCount, more) {
        connection.close();
    });
    connection.execSql(sqlCommand);
});

Here is the error message

RequestError: Validation failed for parameter 'request_UserID'. Cannot read property 'validate' of undefined

I looked into this example - https://docs.microsoft.com/en-us/sql/connect/node-js/step-3-proof-of-concept-connecting-to-sql-using-node-js?view=sql-server-ver15

In the example they do not query using parameters. I need to use parameters to avoid SQL injection

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

The solution was to change TYPES.VARCHAR to TYPES.VarChar

Thanks @AlwaysLearning

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!