SqlConnection - is remote or local connection?

后端 未结 4 1339
星月不相逢
星月不相逢 2021-01-27 20:20

How can I determine is it local connection (localhost or 127.0.0.1) or is it remote connection (other machine in local area) if I have SqlConnection object?

4条回答
  •  广开言路
    2021-01-27 21:10

    Ask SQL using the connection with the statement

    SELECT @@SERVERNAME
    

    then verifiy if this match the name of the client machine with Environment.MachineName, modulo the SQL instance name

提交回复
热议问题