Saturday, August 30, 2008

Finding Distance based on Zipcode or City Name for USA

Finding Distance based on Zipcode or City Name for USA
A really good article sharing how to find distance between two zip codes or cities of USA.

For whom this article is useful

  • It finds distance in miles between two zipcodes of USA.
  • It finds distance in miles between two cities of USA.
  • Finding County based on city or zipcode name.
  • Free Zipcode database of USA
  • Article is written in C#
Finding Distance based on Zipcode or City Name for USA

Note: When you will download the Zipcode of USA Cities and Import to SQL Server, it append inverted comma to data, to remove that you might need to run following update cursor script. Remember you need to change name of column as mentioned in script.

DECLARE c1 CURSOR READ_ONLY
FOR
select ZipCode,Latitude,Longitude,City,State,County,ZipClass from Zip_Codes

declare @ZipCodeOriginal varchar(50)
declare @ZipCode varchar(50)
declare @Latitude varchar(50)
declare @Longitude varchar(50)
declare @City varchar(50)
declare @State varchar(50)
declare @County varchar(50)
declare @ZipClass varchar(50)

open c1
FETCH NEXT FROM c1
Into @ZipCode,@Latitude,@Longitude,@City,@State,@County,@ZipClass
WHILE @@FETCH_STATUS = 0

BEGIN
set @ZipCodeOriginal = @ZipCode
set @ZipCode = substring(@ZipCode,2,len(@ZipCode) - 2)
set @Latitude = substring(@Latitude,2,len(@Latitude) - 2)
set @Longitude = substring(@Longitude,2,len(@Longitude) - 2)
set @City = substring(@City,2,len(@City) - 2)
set @State = substring(@State,2,len(@State) - 2)
set @County = substring(@County,2,len(@County) - 2)
set @ZipClass = substring(@ZipClass,2,len(@ZipClass) - 2)


--Update
update Zip_Codes
set ZipCode=@ZipCode,
Latitude = @Latitude,
Longitude = @Longitude,
City = @City,
State = @State,
County = @County,
ZipClass = @ZipClass
where
--Uniqueness Checking
ZipCode = @ZipCodeOriginal


FETCH NEXT FROM c1
Into @ZipCode,@Latitude,@Longitude,@City,@State,@County,@ZipClass
END
CLOSE c1
DEALLOCATE c1

Thursday, August 28, 2008

SQL Server Utility Functions for Searching String in SQL Server 2005

Set of Utility Function for SQL Server 2005

AT(): Returns the beginning numeric position of the nth occurrence of a character expression within another character expression, counting from the leftmost character.
RAT(): Returns the numeric position of the last (rightmost) occurrence of a character string within another character string.
OCCURS(): Returns the number of times a character expression occurs within another character expression (including overlaps).
OCCURS2(): Returns the number of times a character expression occurs within another character expression (excluding overlaps).
PADL(): Returns a string from an expression, padded with spaces or characters to a specified length on the left side.
PADR(): Returns a string from an expression, padded with spaces or characters to a specified length on the right side.
PADC(): Returns a string from an expression, padded with spaces or characters to a specified length on the both sides.
CHRTRAN(): Replaces each character in a character expression that matches a character in a second character expression with the corresponding character in a third character expression.
STRTRAN(): Searches a character expression for occurrences of a second character expression, and then replaces each occurrence with a third character expression. Unlike a built-in function Replace, STRTRAN has three additional parameters.
STRFILTER(): Removes all characters from a string except those specified.
GETWORDCOUNT(): Counts the words in a string.
GETWORDNUM(): Returns a specified word from a string.
GETNUMWORD(): Returns the index position of a word in a string.
GETALLWORDS(): Inserts the words from a string into the table.
PROPER(): Returns from a character expression a string capitalized as appropriate for proper names.
RCHARINDEX(): Similar to the Transact-SQL function Charindex, with a Right search.
ARABTOROMAN(): Returns the character Roman numeral equivalent of a specified numeric expression (from 1 to 3999).
ROMANTOARAB(): Returns the number equivalent of a specified character Roman numeral expression (from I to MMMCMXCIX).

You can get code from this web link for each of this functions http://it.toolbox.com/wiki/index.php/User-Defined_string_Functions_MS_SQL_Server_2005_Transact-SQL_SQLCLR

Tuesday, August 26, 2008

Avoid Insert Record on Page Refresh in asp.net

Avoid Inserting Duplicate Record on Page Refresh

Problem: User Input Form Inserts Duplicate Record on Page Refresh.

Solution:
This Problem can have 4 different solution, as mention in Article Preventing Duplicate Record on Page Refreshed

According to me among all mention solution, Page Redirect Solution is the best.

Use following piece of code, it will work efficient even with URL displayed with URLRewriting
Response.Redirect(Request.UrlReferrer.AbsoluteUri.ToString());

Friday, August 22, 2008

Finding Search Volume of Keyword SEO

Use the Keyword Tool to get new keyword ideas. Select an option below to enter a few descriptive words or phrases, or type in your website's URL. It also display following information.
  • Keyword
  • Monthly Search Volume
  • Suggestion Bid in $ (How much that keyword is worth)
  • And more information.
http://www.google.com/sktool



Finding Search Volume of Keyword SEO
How to find Search Volume of Keyword.

To Find Search Volume of keyword with the help of Google Keyword Tool.

https://adwords.google.com/select/KeywordToolExternal

Saturday, August 09, 2008

Member names cannot be the save as their enclosing type

Error: Member names cannot be the save as their enclosing type

Possible Cause: Unkowingly I declare Method name, same as class name, which pops-up this error. Logically its out of blue to think, declaring method name as class name as it is constructor, but may be because of nature of application i have declare Class Name as Method Name and runs into Error: "Member names cannot be the save as their enclosing type".

Cause of Error:


public class MyClass
{
//Declaring Method Same as Class Name
//Note: its not constructor, constructor don't have return type.
public void MyClass()
{
}
}
 

Solution to Error:


public class MyClass
{
//Change Method Name to Something else
public void MyMethod()
{
}
}

Monday, August 04, 2008

Free EBooks for LINQ, Ajax, Silverlight

Free E-Books for LINQ, Ajax, Silverlight

Free E-Books for New Features of .Net Framework 3.5

Sign up for the free e-book offer

The free e-book from Microsoft Press:

  • Introducing Microsoft LINQ by Paolo Pialorsi and Marco Russo



    It explains Language Integrated Query (LINQ) syntax fundamentals, LINQ to ADO.NET, and LINQ to XML.





This book explains ASP.NET AJAX Extensions 1.0, including an overview and the control toolkit.




This book explains how to use Silverlight to simplify the way you implement compelling user experiences for the Web. Discover how to support an object-oriented program model with JavaScript.

Most Recent Post

Subscribe Blog via Email

Enter your email address:



Disclaimers:We have tried hard to provide accurate information, as a user, you agree that you bear sole responsibility for your own decisions to use any programs, documents, source code, tips, articles or any other information provided on this Blog.
Page copy protected against web site content infringement by Copyscape