1

Hi I had my code working fine but needed to update the database to a newer version for unrelated issues.

So I have updated my sql server to 18.

Now however I cannot seem to connect my react site to my new database.

I have checked tcp/ip is enabled. I have enabled pipelines. I have checked that the user is mapped to the database in security. I have checked the user is dbreator . Within the database itself I have even just gone as far as given them all memberships and all owned schemas. Within the server mangment tool i spotted it was not connected to a port so I manually added 1433.

This is a basic get route with my config

const config = {
  user: "sas",
  password: "Mypassword123",
  server: ".\\MSSQLSERVER1000", // You can use 'localhost\\instance' to connect to named instance
  database: "TestDBWebsite",
  port: 1433
};

app.use(bodyParser.json());

//AdminView users just pulls the users from the database
app.get("/admin-view-users", function(req, res) {
  // connect to your database
  sql.connect(config, function(err) {
    if (err) console.log(err + "initial connection");

    // create Request object
    var request = new sql.Request();

    // query to the database and get the records
    request.query("select * from Users ", function(err, recordset) {
      if (err) console.log(err);

      // send records as a response

      res.json(recordset);
    });
  });
});

This is the error I receive

ConnectionError: Failed to lookup instance on . - getaddrinfo EAI_AGAIN  initial connection

What could be causing this? How would I fix this? The only thing changed within the initial code is the database table names to the ones they are updated within and of course the config was updated also.

PLease help any answers are appreciated.

coderStew
  • 137
  • 2
  • 13
  • Is this relevant? https://stackoverflow.com/questions/55641248/unable-to-connect-to-microsoft-sql-server-using-node-js-mssql-and-express – Keith Jan 10 '20 at 11:23
  • Or this https://github.com/tediousjs/node-mssql/issues/17 – Keith Jan 10 '20 at 11:24

0 Answers0