0

我已经导入了 maxmind Dll 并下载了 GeoIp.dat 数据库以获取 IP 地址的国家名称我使用了以下代码

        Dim ls As New LookupService("GeoIP.dat", LookupService.GEOIP_MEMORY_CACHE)
        'get country of the ip address

        Dim c As Country = ls.getCountry("24.24.24.24")
        Console.Write(" code: " & c.getCode() & vbLf)
        Console.Write(" name: " & c.getName() & vbLf)
        CountryName.Text = " name: " & c.getName() & vbLf

Dim c As Country = ls.getCountry("24.24.24.24")

给我以下错误数据库已关闭。可能是什么问题呢

4

1 回答 1

0

我应该这样写

Dim ls As New LookupService(MapPath ("GeoIP.dat"), LookupService.GEOIP_MEMORY_CACHE)
    Dim c As Country = ls.getCountry("24.24.24.24")
    Console.Write(" code: " & c.getCode() & vbLf)
    Console.Write(" name: " & c.getName() & vbLf)
    CountryName.Text = " name: " & c.getName() & vbLf
于 2013-08-05T11:27:09.947 回答