0

I want to connect to a SQL SERVER on my machine through google sheets. I have port forwarded, set up appropriate firewalls and started the server browser and all of these are working. Here is the jdbc connection string I am using

  var conn = Jdbc.getConnection("jdbc:sqlserver://x.x.x.x:x;databaseName=anviz;user=sa;password=sa");
  if(conn.isClosed()==false){Logger.log("closed");};

When I run this, I get We're sorry, a server error occurred. Please wait a bit and try again. (line x, file "Code") This means at least to me that the connection string is not set up properly. Does anyone know how to set it up so that it can connect to SQL SERVER 2012?

sakib11
  • 496
  • 1
  • 5
  • 20

1 Answers1

0

The issues were

  1. Database was not accepting connections from outside the network because for sqlserver you must have port 1434 and sqlbrowser enabled.
  2. The connection string may have been wrong (I did not test it with the old one after I had fixed the server port issue) but here is the new connection string
  var address = 'ip:port';
  var user = 'x';
  var userPwd = 'x';
  var db = 'x';
  var dbUrl = 'jdbc:sqlserver://' + address + ';databaseName=' + db;
  var conn = Jdbc.getConnection(dbUrl, user, userPwd);
sakib11
  • 496
  • 1
  • 5
  • 20