maxMind GeoIP数据库未打开



我已经导入了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")

给我以下错误数据库已关闭。有什么问题

我应该这样写

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

相关内容

  • 没有找到相关文章

最新更新