TheosOfWar
TheosOfWar

Reputation: 1

Buffer Not defined

I'm trying to setup a connection to an SQL Server database on a private server. but when I try to implement the connection function I'm getting a buffer not defined error in browser.

this.config = {
server: 'server',
port: port,
database: 'database',
user: 'user',
password: 'password',
driver:'jdbc:sqlserver'
};

connect() {
try {
// Create a new pool
const pool =  new sql.ConnectionPool(this.config).connect();
console.log('Connected to the database.');
return pool;
} catch (err) {
console.error('Error connecting to the database:', err);
throw err;
}
}

I have also tired this function

async connectToDatabase() {
try {

      await sql.connect(this.config);
      console.log('Connected to the database successfully!');
      // Perform database operations here
    } catch (error) {
      console.error('Error connecting to the database:', error);
    }

}

//implementation
  async checkConnection(): Promise<boolean> {
    let allow: boolean;
    let pool = new DataBaseConnection();
    await pool.connect();
    allow = !!pool;
    allow=true;
    return allow;
}

and I'm getting this error

Uncaught referenceError: buffer is not defined at node_modules/mssql/lib/shared.js (shared.js:39:14) at __require(chunk-sk7rekqt.js?v=ff639fc5:43:50

Upvotes: 0

Views: 159

Answers (0)

Related Questions