1.阿江IP库的offip 和onip指的是什么?
2.原理是什么?
3.用什么算法,可以更快速、有效的查询出IP所在国家、省份、及市?
4.有否更好的办法?
-------分很多:
希望得到正确的解答。谢谢
2.原理是什么?
3.用什么算法,可以更快速、有效的查询出IP所在国家、省份、及市?
4.有否更好的办法?
-------分很多:
希望得到正确的解答。谢谢
调试欢乐多
算法如下: public static string GetAddressByIP(string ip)
{
string reValue="未知位置";
DataBase GetData=new DataBase("Temp");
string ipAddress=ip;
string[] ips=ipAddress.Split('.');
Int64 myIP;
myIP=Convert.ToInt64(ips[0])*16777216;
myIP+=Convert.ToInt64(ips[1])*65535;
myIP+=Convert.ToInt64(ips[2])*256;
myIP+=Convert.ToInt64(ips[3]);
SqlConnection conn=new SqlConnection(GetData.MyConnectionString);
conn.Open();
SqlCommand myCmd=new SqlCommand("GetAddressByIP",conn);
myCmd.CommandType=CommandType.StoredProcedure;
myCmd.Parameters.Add("@ip",SqlDbType.BigInt);
myCmd.Parameters["@ip"].Value=myIP;
SqlDataReader readIP=myCmd.ExecuteReader();
if(readIP.Read())
{
reValue=readIP["Address"].ToString();
}
else
{
reValue="未知位置";
}
readIP.Close();
myCmd.Dispose();
conn.Close();
conn.Dispose();
return reValue;
}