以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  [原创]如何获取外部SQL数据源IP地址  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=150520)

--  作者:洮沙
--  发布时间:2020/6/1 10:00:00
--  [原创]如何获取外部SQL数据源IP地址

帮助文档中有“获取外部SQL数据源的时间”例子如下,计划获取数据源的ip地址,如何实现?

 

Dim cmd As New SQLCommand
Dim
dt As Date
cmd.ConnectionName =
"数据源名称"
cmd.CommandText =
"S elect GetDate()"
dt = cmd.ExecuteScalar()
dt = dt.
Date

 

或者,提供一下,如何判断SQL数据库是在本机还是网络上的代码?

 

麻烦老师帮忙看看,谢谢!


--  作者:有点蓝
--  发布时间:2020/6/1 10:08:00
--  
如果IP有写在链接字符串里,可以通过分析链接字符串获取:http://www.foxtable.com/webhelp/topics/1943.htm

Dim s As String = Connections("t").ConnectionString
Dim i As Integer = s.IndexOf("Data Source=")
If  i > -1 Then
    msgbox(s.SubString(i))
End If


--  作者:洮沙
--  发布时间:2020/6/1 11:00:00
--  回复:(有点蓝)如果IP有写在链接字符串里,可以通过...
合适了,还是自己对帮助文件看的不透彻,谢谢蓝版!