Exemple #1
0
		public IPAddressDetails Details(string IPAddress)
		{
			try
			{
                SqlConnection myConnection = new SqlConnection(System.Configuration.ConfigurationManager.AppSettings["IPAddressConnectionString"]);
				SqlCommand myCommand = new SqlCommand("usp_IPDetails",myConnection);

				myCommand.CommandType = CommandType.StoredProcedure;
				
				int IPNumber = ToIPNumber(IPAddress);

				SqlParameter prmIPAddress = new SqlParameter("@IPAddress", SqlDbType.Float);
				prmIPAddress.Value =  IPNumber;
				myCommand.Parameters.Add(prmIPAddress);

				SqlParameter prmCountryCode = new SqlParameter("@CountryCode", SqlDbType.VarChar, 10);
				prmCountryCode.Direction = ParameterDirection.Output;
				myCommand.Parameters.Add(prmCountryCode);

				SqlParameter prmCountry = new SqlParameter("@Country", SqlDbType.VarChar, 15);
				prmCountry.Direction = ParameterDirection.Output;
				myCommand.Parameters.Add(prmCountry);

				myConnection.Open();
				myCommand.ExecuteNonQuery();
				myConnection.Close();

				IPAddressDetails Details = new IPAddressDetails();

				Details.IPAddress = IPAddress;
				Details.IPNumber = IPNumber;
				Details.CountryCode = "" + prmCountryCode.Value; 
				Details.Country = "" + prmCountry.Value;				

				return Details;
			}
			catch(Exception ex)
			{
				throw ex;
			}
		}
Exemple #2
0
        public IPAddressDetails Details(string IPAddress)
        {
            try
            {
                SqlConnection myConnection = new SqlConnection(System.Configuration.ConfigurationManager.AppSettings["IPAddressConnectionString"]);
                SqlCommand    myCommand    = new SqlCommand("usp_IPDetails", myConnection);

                myCommand.CommandType = CommandType.StoredProcedure;

                int IPNumber = ToIPNumber(IPAddress);

                SqlParameter prmIPAddress = new SqlParameter("@IPAddress", SqlDbType.Float);
                prmIPAddress.Value = IPNumber;
                myCommand.Parameters.Add(prmIPAddress);

                SqlParameter prmCountryCode = new SqlParameter("@CountryCode", SqlDbType.VarChar, 10);
                prmCountryCode.Direction = ParameterDirection.Output;
                myCommand.Parameters.Add(prmCountryCode);

                SqlParameter prmCountry = new SqlParameter("@Country", SqlDbType.VarChar, 15);
                prmCountry.Direction = ParameterDirection.Output;
                myCommand.Parameters.Add(prmCountry);

                myConnection.Open();
                myCommand.ExecuteNonQuery();
                myConnection.Close();

                IPAddressDetails Details = new IPAddressDetails();

                Details.IPAddress   = IPAddress;
                Details.IPNumber    = IPNumber;
                Details.CountryCode = "" + prmCountryCode.Value;
                Details.Country     = "" + prmCountry.Value;

                return(Details);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }