'// Encounter: Unable to retrieve data from the table.
// My Code
const sql = require('mssql/msnodesqlv8');
const poolPromise = new sql.ConnectionPool({
driver: 'msnodesqlv8',
server: "test.database.windows.net",
user: "username",
password: "password",
database: 'database',
port: 1433,
})
.connect()
.then((pool: any) => {
console.log('Connected to MSSQL')
return pool
})
.catch((err: any) => console.log('Database Connection Failed! Bad Config: ', err))
;
describe('dummy test', () => {
it('validation', async () => {
try
{
const pool = await poolPromise;
const result = await pool.request()
.query('select * from table where username = "Protractor"');
console.log(result);
}
catch(err)
{
console.log(err);
}
});
});
Error Identified:
[13:20:25] I/launcher - Executing 1 instance of WebDriver
[13:20:25] I/hosted - Using the selenium server at http://localhost:4444/wd/hub
Started
Connected to MSSQL
{ RequestError: Invalid column name 'Protractor'.
at handleError (C:\Users\automation\node_modules\mssql\lib\msnodesqlv8\request.js:258:21)
at StreamEvents.emit (events.js:189:13)
at errors.forEach.err (C:\Users\automation\node_modules\msnodesqlv8\lib\reader.js:37:20)
at Array.forEach ()
at routeStatementError (C:\Users\automation\node_modules\msnodesqlv8\lib\reader.js:30:14)
at invokeObject.end (C:\Users\automation\node_modules\msnodesqlv8\lib\reader.js:209:11)
at freeStatement (C:\Users\automation\node_modules\msnodesqlv8\lib\driver.js:183:13)
at cppDriver.freeStatement (C:\Users\automation\node_modules\msnodesqlv8\lib\driver.js:163:13) originalError:
{ Error: [Microsoft][SQL Server Native Client 11.0][SQL Server]Invalid column name 'Protractor'. sqlstate: '42S22', code: 207 },
name: 'RequestError',
number: 207,
state: '42S22' }