用于远程连接到SQL Server的IP?

时间:2017-12-23 22:04:52

标签: sql-server node.js

我正在尝试从Node远程连接到Microsoft SQL Server(使用node-mssql)。

var sql = require('mssql')

var config = {
  server:   '**',
  user:     '**',
  password: '**!',
  database: '**'
}

sql.connect(config, function(err) {
  var request = new sql.Request()
  request.query("select *", function(err, recordset) {
    console.log(err)
    console.log(recordset)
  })
  console.log('end')
})

我从服务器运行以下查询:

SELECT  
   CONNECTIONPROPERTY('net_transport') AS net_transport,
   CONNECTIONPROPERTY('protocol_type') AS protocol_type,
   CONNECTIONPROPERTY('auth_scheme') AS auth_scheme,
   CONNECTIONPROPERTY('local_net_address') AS local_net_address,
   CONNECTIONPROPERTY('local_tcp_port') AS local_tcp_port,
   CONNECTIONPROPERTY('client_net_address') AS client_net_address 

基于SQL - Query to get server's IP address

我是否使用client_net_address远程连接,或使用server参数的其他IP?

1 个答案:

答案 0 :(得分:1)

如果从同一台计算机上的应用程序进行连接,请使用local_net_address