How to Only Allow Numbers in A TextBox

October 13, 2008

I came across a problem the other day. I was working on a ASP.NET application written on the .NET 1.1 Framework and I need to restrict two text box controls to only allow numbers. Being written for 1.1, I did not have access to the slick AJAX Control Toolkit which I could had easily thrown on a extender to force only numbers, thus I had to resort to good old JavaScript!

There actually were lots of examples of doing this on the Internet, but it was challenging to find one that worked period or would work in multiple browsers! Finally, after doing extensive searches and tweaks, here is the final function I used to restrict a text box to only accept numbers:

Javascript Function


// A function that only allows numbers to be typed into a text field.
function NumberValidation(event)
{
var charCode = (event.which) ? event.which : event.keyCode;

return !(charCode > 31 && (charCode < 48 || charCode > 57));
}

ASP.NET Code


<asp:TextBox ID="PageSize" Runat="server" style="width:30px;" MaxLength="3" OnKeyPress="return NumberValidation(event);"></asp:TextBox>

*Note: Even though Visual Studio will indicate you cannot have OnKeyPress in the aspx, you can still put it there and it will work.


Setting the SSDIR environment variable in Microsoft Visual Source Safe

July 27, 2008

I have this problem crop up every once in awhile with using the command
line of Visual Source Safe 2005. I attempt to perform a task and I receive and error back saying “No VSS database (srcsafe.ini) found. Set the SSDIR environment variable to the path of srcsafe.ini for your VSS database.”

To correct this problem, open the command window and go to C:\Program Files\Microsoft Visual SourceSafe

Execute the following command:

set ssdir=\\yourserver\VSS\VSProjects

This should work, of course, verify where your srcsafe.ini file is located before setting the variable.

-Flea#


Coalition Doctors Remove Tumor, Save Afghan Girl’s Life

July 15, 2008

I saw this article from the Department of Defense today and thought it was just an incredible story! Especially for those people who believe the war on terror is nothing but a U.S. occupation.

———————————————————————————–

Coalition Doctors Remove Tumor, Save Afghan Girl’s Life
By Army Sgt. Daniel Love
Special to American Forces Press Service
BAGRAM AIRFIELD, Afghanistan, July 15, 2008 – On a warm morning in early June, a worried Abdullah Haqim walked with his daughter into the weekly coalition medical clinic in Afghanistan’s Farah province. Six-year-old Gulzana was sick, and local Afghan doctors could not diagnose or treat the painful swelling that had engulfed her left eye.
 


Gulzana Haqim, a 6-year-old Afghan girl, and her father, Abdullah, arrive at Bagram Airfield, Afghanistan, July 9, 2008. Gulzana was treated for a tumor over her eye at Craig Joint Theater Hospital. U.S. Army photo by Sgt. Daniel Love, Combined Joint Special Operations Task Force
(Click photo for screen-resolution image);high-resolution image available.

The father watched with a worried expression as a U.S. special operations forces doctor examined the tumor that covered her eye. He was worried because insurgents in the area had warned him that coalition doctors would not help his daughter and may even hurt her.

“This wasn’t the type of thing we could treat at the weekly clinic,” the doctor said. “Most of our patients here require more basic assistance. Her case required advanced medical care as quickly as we could provide it, so we had to start making plans right away if we were to have a chance of saving her.”

Gulzana had an orbital tumor growing from her eye that was expanding to her cheek and eyebrow. In a developing country such as Afghanistan, a child with such an affliction has an extremely low chance of survival. Soon after the American doctor looked at her, he began coordinating life-saving plans.

“We saw this as a case where we could make a difference in a child’s life, so we had to act,” the doctor said. “It took some effort, but we arranged for Gulzana and her father to arrive here around the same time as Col. David Holck, one of the Air Force’s two best optical surgeons.”

On the morning of July 7, Holck began his trek here from Baghdad by way of military resupply flights. Holck is chairman of ophthalmology at Wilford Hall Medical Center, at Lackland Air Force Base, Texas. Throughout the same day, Gulzana and her father travelled 14 hours on a bus to Bagram to meet with the doctor.

Haqim, carrying a makeshift travel bag made from a bed sheet, finally met the doctor who would save his daughter’s life. Medics changed Gulzana’s bandages, and she received a teddy bear from adoring U.S. troops. She shied away from the attention.

The next day, Holck and other coalition doctors scanned Gulzana’s head to gauge the size and location of the tumor. Like most children, she didn’t seem to like being in the hospital, but she was patient and allowed the medical staff at the Craig Joint Theater Hospital here to examine her and plan the required surgery. The tumor had spread from her retina to other parts of her eye, but had not yet affected her skull or brain.

“Based on her scan, we could see that the situation was a little better than we had hoped for,” Holck said. “You can’t beat the positive outcome of something like this; all we have to do is our job, but we also get the opportunity to make a difference in a child’s life.”

The following day, Gulzana was on an operating table, surrounded by Air Force and Army doctors. The operation lasted two hours, but when it was finished, she looked like a new child. The tumor was gone, and her eyelid could close. She woke up with bandages on her face and with her happy father holding her hand.

Gulzana and her father will temporarily live here as she recovers. Her smile warms the hearts of the servicemembers who monitor her recovery, and the worried look on her father’s face is gone.

“Her mother is gone, and she has had enough pain in her life,” Haqim said. “I’m happy that the Americans showed so much care for her and that she is getting better. Before, we were so worried, but now everything has changed and she will have a chance to grow up and be happy.”


Operation Iraqi Freedom: How the United States is Not Occupying the Country of Iraq

July 13, 2008

In the media and especially in the blogosphere the idea of the United States as being an occupying force in Iraq is gaining un-founded momentum. I have yet to find a compelling reason from anyone on how you could consider the United States occupying the country of Iraq.

We aren’t there for oil; that is a fact. The price of gas is sky rocketing in the United States, causing our economy to slow to the point of recession. If we were there for oil, we should have cheap gas, but we don’t, the exact opposite is happening. If the United States was there to just occupy, why are we building schools, hospitals, roads and other infrastructure? Why is the United States training the Iraqi army and police force? If we are there for our own selfish reasons, then there would be no need to spending billions of American dollars to re-build this country.

U.S. Navy Petty Officer 2nd Class Jason Nolte, center, instructs an Iraqi policeman on boating techniques at Lake Quadsiyah in Haditha, Iraq, July 7, 2008. Nolte is assigned to Riverine Squadron 3, Detachment 2, Regimental Combat Team 5.


Iraq Wants U.S. Soldiers To Return Home – A Response to Aisha Music

June 27, 2008

 As a common liberal who is un-informed and un-aware of the world, I am responding to a foolish post by Aisha Music titled Iraq Wants U.S. Soldiers To Return Home. Aisha conveniently disabled commenting on her article, thus preventing any type of intellectual challenge to her thoughts. While not surprising, it is unfortunate.

Aisha, you are completely off base with your idea that George Bush is occupying Iraq for oil. The price of oil has caused record high gas prices in the United States, causing the United States economy among other things to slow to a halt! The United States is not seeing any benefit of Iraqi oil which is unfortunate; unfortunate because billions of American tax dollars are being spent to free a country which you claim does not even want Americans there.

You might not like the war, which is fine, I don’t care for it myself, but don’t try and spread lies about Bush or the United States getting rich off of oil because that is just false and you know it.

I don’t really believe the fact that the Iraqi’s want us out of Iraq, mainly because they know the moment we leave their country would be taken over by Iran or some other radical. But you know what, if they truly want us out, fine, because they are not worth one American life and you must think so, considering you think Saddam Hussein was better for Iraqis then being free.

-Flea#


The Price of Prejudice – A Response to Portfolio Magazine

June 23, 2008

Portfolio Magazine, a left slanted business magazine wrote this edititorial commentary about why business should support gay marriage. I emailed the following response back to their editors (letters@portfolio.com) and also posted it on their blog.

————–

To the Editors of Portfolio Magazine,

 

I just finished reading your commentary The Price of Prejudice, where you commend the Supreme Court of California for overturning the vote of the people to legalize gay marriage. I think your appeal to business and capitalist to push for gay marriage to “recruit, retain and motivate the best and the brightest” is unfortunate and incorrect. The United States has been an economic powerhouse for decades, if not a century, without the need for gay marriage. Your warning to us that countries such as “Canada, Spain and South Africa” are legalizing gay marriage, therefore we should be concerned about losing top notch talent and business is laughable. The United States had an estimated $13.84 trillion GDP  in 2007, where as Spain had $1.352 trillion, Canada was at $1.266 trillion and South Africa…..wait are you ready for this….  $467.1 billion GDP.

 

The most unfortunate realization about this article you wrote is that you completely deny the fact that the voters of California were overruled by the courts. You then go on to say how the “majority of Americans” oppose same-sex marriage. You should be writing an article about how disgusting and un-American it is for courts to overrule the people.

 

Your socialist agenda is going down a slippery slope when you favor activist courts over the vote of the people. I would hate for your magazine some day to get squelched by some activist court or government as your brethren in Iran have recently faced with the shut down of that Iranian Daily newspaper who simply opposed the Government.

 

I would protest your magazine by not paying for it and cancelling my subscription, but I don’t pay for it, I read it for free at the library.  Isn’t socialism great? ;-)


Windows Firewall and C#

June 19, 2008

This is great for any type of application that requires access to a network. I wrote this WindowsFirewall class that dumps out configuration settings for the Windows Firewall of a local machine. Currently, in this example it just spits it to the console, however, you can dump it to a text file easily. I found a similar example here using VB.NET. Also, Shafqat Ahmed’s .NET Blog had some other examples!

To begin, you will need to add a reference in your project to the COM assembly hnetcfg.dll which can be found at C:\Windows\System32\hnetcfg.dll


using System;
using NATUPNPLib;
using NETCONLib;
using NetFwTypeLib;

namespace ListOfProcesses
{
	/// <summary>
	/// A class that contains methods to display the current information
	/// about the local computers Windows Firewall.
	/// </summary>
	public class WindowsFirewall
	{
		#region Constants

		private const string CLSID_FIREWALL_MANAGER = "{304CE942-6E39-40D8-943A-B913C40C9CD4}";
		private const NET_FW_PROFILE_TYPE_ NET_FW_PROFILE_DOMAIN = NET_FW_PROFILE_TYPE_.NET_FW_PROFILE_DOMAIN;
		private const string LINE_HEADER = "--------------------------------------------------------------------------------";
		private const string SHORT_LINE_HEADER = "-----------------";

		#endregion

		#region Constructor

		public WindowsFirewall()
		{

		}

		#endregion

		#region Public Methods

		/// <summary>
		/// Displays a comprehensive list of information regarding the Windows Firewall
		/// </summary>
		public void DisplayFirewallInformation()
		{
			INetFwMgr manager = GetFirewallManager();

			this.DisplayFirewallProfile(manager);
		}

		#endregion

		#region Private Methods

		/// <summary>
		/// Returns a firewall manager object
		/// </summary>
		/// <returns>INetFwMgr interface</returns>
		private static INetFwMgr GetFirewallManager()
		{
			Type objectType = Type.GetTypeFromCLSID(new Guid(CLSID_FIREWALL_MANAGER));

			return Activator.CreateInstance(objectType) as NetFwTypeLib.INetFwMgr;
		}

		/// <summary>
		/// Writes out various firewall configurations for the local firewall policy.
		/// </summary>
		/// <param name="manager">INetFwMgr object</param>
		private void DisplayFirewallProfile(INetFwMgr manager)
		{

			INetFwProfile profile = manager.LocalPolicy.CurrentProfile;

			/*
			 *
			 * Profile Information
			 *
			 */

			Console.Write(WindowsFirewall.LINE_HEADER);
			Console.WriteLine("Windows Firewall Report\n");
			Console.WriteLine("\n\n{0}\n{1}", "Profile", WindowsFirewall.SHORT_LINE_HEADER);
			Console.WriteLine("Firewall Policy Type: {0}", this.GetPolicyType(profile));
			Console.WriteLine("Exceptions Not Allowed: {0}", profile.ExceptionsNotAllowed);
			Console.WriteLine("Notifications Disabled: {0}", profile.NotificationsDisabled);
			Console.WriteLine("Remote Administration Enabled: {0}", profile.RemoteAdminSettings.Enabled);

			/*
			 *
			 * ICMP Settings
			 *
			 */

			Console.WriteLine("\n\n{0}\n{1}", "ICMP Settings", WindowsFirewall.SHORT_LINE_HEADER);
			Console.WriteLine("Allow Inbound Echo Request: {0}", profile.IcmpSettings.AllowInboundEchoRequest);
			Console.WriteLine("Allow Inbound Mask Request: {0}", profile.IcmpSettings.AllowInboundMaskRequest);
			Console.WriteLine("Allow Inbound Router Request: {0}", profile.IcmpSettings.AllowInboundRouterRequest);
			Console.WriteLine("Allow Inbound TimeStamp Request: {0}", profile.IcmpSettings.AllowInboundTimestampRequest);
			Console.WriteLine("Allow Outbound Destination Unreachable: {0}", profile.IcmpSettings.AllowOutboundDestinationUnreachable);
			Console.WriteLine("Allow Outbound Packet Too Big: {0}", profile.IcmpSettings.AllowOutboundPacketTooBig);
			Console.WriteLine("Allow Outbout Parameter Problem: {0}", profile.IcmpSettings.AllowOutboundParameterProblem);
			Console.WriteLine("Allow Outbound Source Quench: {0}", profile.IcmpSettings.AllowOutboundSourceQuench);
			Console.WriteLine("Allow Outbound Time Exceeded: {0}", profile.IcmpSettings.AllowOutboundTimeExceeded);
			Console.WriteLine("Allow Redirect: {0}", profile.IcmpSettings.AllowRedirect);

			/*
			 *
			 * Port Information
			 *
			 */

			Console.WriteLine("\n\n{0}\n{1}", "Port Information", WindowsFirewall.SHORT_LINE_HEADER);
			Console.WriteLine("Globally Opened Ports: {0}", profile.GloballyOpenPorts.Count);

			// Display detailed port information.
			foreach (INetFwOpenPort port in profile.GloballyOpenPorts)
			{
				Console.WriteLine("\n\nPort Name: {0}", port.Name);
				Console.WriteLine("{0, 20}{1}", "Port Number: ", port.Port);
				Console.WriteLine("{0, 20}{1}", "Port Protocol: ", this.GetPortType(port));
				Console.WriteLine("{0, 20}{1}", "Port IP Version: ", this.GetIPVersion(port));
				Console.WriteLine("{0, 20}{1}", "Port Enabled: ", port.Enabled);
				Console.WriteLine("{0, 20}{1}", "Remote Addresses: ", port.RemoteAddresses);
			}

			/*
			 *
			 * Service Information
			 *
			 */

			Console.WriteLine("\n\n{0}\n{1}", "Services Information", WindowsFirewall.SHORT_LINE_HEADER);
			Console.WriteLine("# of Services: {0}", profile.Services.Count);

			// Display detailed service information.
			foreach (INetFwService service in profile.Services)
			{
				Console.WriteLine("\n\nService Name: {0}", service.Name);
				Console.WriteLine("{0, 20}{1}", "Enabled: ", service.Enabled);
				Console.WriteLine("{0, 20}{1}", "Scope: ", this.GetServiceScope(service));

				// Obtain all the port information the service is utilizing.
				foreach (INetFwOpenPort port in service.GloballyOpenPorts)
				{
					Console.WriteLine("{0, 20}{1}", "Port Number: ", port.Port);
					Console.WriteLine("{0, 20}{1}", "Port Protocol: ", this.GetPortType(port));
					Console.WriteLine("{0, 20}{1}", "Port IP Version: ", this.GetIPVersion(port));
					Console.WriteLine("{0, 20}{1}", "Port Enabled: ", port.Enabled);
					Console.WriteLine("{0, 20}{1}", "Remote Addresses: ", port.RemoteAddresses);
				}
			}

			/*
			 *
			 * Authorized Applications
			 *
			 */

			Console.WriteLine("\n\n{0}\n{1}", "Authorized Applications", WindowsFirewall.SHORT_LINE_HEADER);
			Console.WriteLine("# of Authorized Applications: {0}", profile.AuthorizedApplications.Count);

			// Display detailed authorized application information.
			foreach (INetFwAuthorizedApplication application in profile.AuthorizedApplications)
			{
				Console.WriteLine("\n\nApplication Name: {0}", application.Name);
				Console.WriteLine("{0, 20}{1}", "Enabled: ", application.Enabled);
				Console.WriteLine("{0, 20}{1}", "Remote Addresses: ", application.RemoteAddresses);
				Console.WriteLine("{0, 20}{1}", "File Path: ", application.ProcessImageFileName);
			}

		}

		/// <summary>
		/// Returns a friendly string format of the policy type.
		/// </summary>
		/// <param name="profile">INetFwProfile object</param>
		/// <returns>string</returns>
		private string GetPolicyType(INetFwProfile profile)
		{
			string policyType = string.Empty;

			// Displays what type of policy the Windows Firewall is controlled by.
			switch (profile.Type)
			{
				case NET_FW_PROFILE_TYPE_.NET_FW_PROFILE_DOMAIN:
					policyType = "Domain";
					break;

				case NET_FW_PROFILE_TYPE_.NET_FW_PROFILE_STANDARD:
					policyType = "Standard";
					break;

				case NET_FW_PROFILE_TYPE_.NET_FW_PROFILE_CURRENT:
					policyType = "Current";
					break;

				case NET_FW_PROFILE_TYPE_.NET_FW_PROFILE_TYPE_MAX:
					policyType = "Max";
					break;

			}

			return policyType;
		}

		/// <summary>
		/// Returns a friendly string format of the type of protocol.
		/// </summary>
		/// <param name="port">INetFwOpenPort port object</param>
		/// <returns>string</returns>
		private string GetPortType(INetFwOpenPort port)
		{
			string protocolType =  string.Empty;

			switch (port.Protocol)
			{
				case NetFwTypeLib.NET_FW_IP_PROTOCOL_.NET_FW_IP_PROTOCOL_TCP:
					protocolType = "TCP";
					break;

				case NetFwTypeLib.NET_FW_IP_PROTOCOL_.NET_FW_IP_PROTOCOL_UDP:
					protocolType = "UDP";

					break;
			}

			return protocolType;
		}

		/// <summary>
		/// Returns a friendly string format of the IP version.
		/// </summary>
		/// <param name="port">INetFwOpenPort port object</param>
		/// <returns>string</returns>
		private string GetIPVersion(INetFwOpenPort port)
		{
			string ipVersion = string.Empty;

			switch (port.IpVersion)
			{
				case NetFwTypeLib.NET_FW_IP_VERSION_.NET_FW_IP_VERSION_ANY:
					ipVersion = "Any";
					break;

				case NetFwTypeLib.NET_FW_IP_VERSION_.NET_FW_IP_VERSION_MAX:
					ipVersion = "Max";
					break;

				case NetFwTypeLib.NET_FW_IP_VERSION_.NET_FW_IP_VERSION_V4:
					ipVersion = "IPV4";
					break;

				case NetFwTypeLib.NET_FW_IP_VERSION_.NET_FW_IP_VERSION_V6:
					ipVersion = "IPV6";
					break;
			}

			return ipVersion;
		}

		/// <summary>
		/// Returns a friendly string format of the service scope.
		/// </summary>
		/// <param name="service">INetFwService object</param>
		/// <returns>string</returns>
		private string GetServiceScope(INetFwService service)
		{
			string serviceScope = string.Empty;

			switch (service.Scope)
			{
				case NetFwTypeLib.NET_FW_SCOPE_.NET_FW_SCOPE_ALL:
					serviceScope = "All";
					break;

				case NetFwTypeLib.NET_FW_SCOPE_.NET_FW_SCOPE_CUSTOM:
					serviceScope = "Custom";
					break;

				case NetFwTypeLib.NET_FW_SCOPE_.NET_FW_SCOPE_LOCAL_SUBNET:
					serviceScope = "Local Subnet";
					break;

				case NetFwTypeLib.NET_FW_SCOPE_.NET_FW_SCOPE_MAX:
					serviceScope = "Max";
					break;
			}

			return serviceScope;
		}

		#endregion
	}
}

IntelliSense stops working in Visual Studio 2008

May 1, 2008

I had an annoying problem in Visual Studio 2008 that cost me about 3 hours of time. I was working in C# and noticed that my IntelliSense had ceased to work. I went into the options under C# and sure enough IntelliSense was still checked; so I removed the checks, hit OK, restarted Visual Studio, came back in and turned IntelliSense back on. However. It still did not work.

3 hours later, I found the source of my problem. The “Auto list members” check box was no longer checked, thus disabling IntelliSense. This was obscure because one would have thought something with this much control over IntelliSense would have actually been on the IntelliSense settings form but, either way, it fixed the problem as soon as I added the check back.

So if your IntelliSense stops working, make sure you have the “Auto list members” box selected.

1.Goto Tools | Options
2.Text Editor
3.C#
4.General
5.Check ‘Auto list members’


The Pain of Christian Humility

April 18, 2008

As Pope Benedict visits America, like any good Catholic I am lingering on every article, glued to every video clip, as I gush with excitement of the Holy Father as he makes his way from venue to venue. Even though our media is slanted far to the left with Christianity usually in their cross-hairs, I think even the media has been, well, almost excited too!

However, an incident really infuriated me this week; Nancy Pelosi kissing the hand of the Holy Father after he arrived at the White House. Pelosi, a Catholic herself has a critical flaw; she supports abortion.

Fast Fact: Besides the kiss of the hand, Pelosi and John Kerry, who also supports abortion, participated in the Eucharist during the open air Mass at the National’s stadium.

As I saw this I was sickened. How could the Pope allow Pelosi to kiss his hand? I know I am not perfect, I don’t follow all of the practices of the Church (such as praying the rosary, going to weekly confession) but to me I am much better than her; for I support life, I don’t want to extinguish it! I don’t get this, here I am, a much better Christian than she will ever be, yet she is granted the privilege of meeting the Pope and kissing his hand yet I am not?

I imagined, if I were standing there next to the Pope I would have said, “Father, this woman supports abortion; amid the other things she goes against, she has no right to kiss your hand, especially when there are millions of others, more faithful then her who deserve this blessed opportunity!” I realized then, as my day dream bubble burst, how wrong I actually was. What I thought was my faithful discipleship, actually was going against what Jesus had commanded and I wasn’t alone in this error.

I remembered the story of Jesus and two of his disciples, James and John:

Luke 9:51-56:

When the days were approaching for His ascension, He was determined to go to Jerusalem; and He sent messengers on ahead of Him, and they went and entered a
village of the Samaritans to make arrangements for Him. But they did not receive Him, because He was traveling toward Jerusalem. When His disciples James and
John saw this, they said, “Lord, do You want us to command fire to come down
from heaven and consume them?” But He turned and rebuked them, [and said, "You
do not know what kind of spirit you are of; for the Son of Man did not come to
destroy men's lives, but to save them."] And they went on to another village.

Fast Fact: Jesus was not welcomed because his disciples and him were Jewish; which during this time, the Samarians and the Jews were bitter enemies.

I sat there and realized, I was like James and John; so dedicated to Jesus, that, those who rejected him or in my case, a Catholic who supported abortion, left me wanting to command my own fire from heaven, to bar Pelosi from meeting the Pope; to prevent her disgraced lips from touching his hand. The words of Jesus rebuking his disciples were now shamelessly tearing into me; I was the one who was wrong; I was the one who was not serving the Lord. My selfishness could have prevented someone who was lost from coming to the light; all because I felt she was not worthy to share the peace of the Lord. I realize now that having Pelsoi enjoy an experience that I wish I had, but do not need, would be for the best. Maybe this experience would change her heart; maybe she would find God.

For a simple kiss on the hand can change perspectives, feelings and hearts; I know; because it changed mine.

-Flea#


US Zip Code Table for SQL 2005

March 23, 2008

I am working on a web application that requires that the user to enter in a zip code and then the city and state would be returned. This type of functionality is quite common, but for some of us developers, we don’t want to pay for the data needed to make this happen. Granted, it didn’t take me too long to find a free table of zip codes, but I did have to do some minor work to hook it all up. So, just to add to the bounty of the Internet, I’ve uploaded the CSV file to one of my servers for you to download along with instructions below for inserting it into your SQL 2005 database. Since this is in a CSV file, you can also use it for MySQL or any other database.

  1. Click here for the ZIPCODE CSV file. Download it to the root of C, just something simple.

  2. Run the following SQL to create the ZipCode table in your database:

SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

SET ANSI_PADDING ON
GO

CREATE TABLE [dbo].[ZipCode]
(
[ZipCode] [varchar](10) NOT NULL,
[Latitude] [varchar](50) NOT NULL,
[Longitude] [varchar](50) NOT NULL,
[City] [varchar](200) NOT NULL,
[State] [varchar](50) NOT NULL,
[County] [varchar](70) NOT NULL,
[ZipClass] [varchar](50) NOT NULL
) ON [PRIMARY]
GO

  1. Run the Bulk Insert command to load the CSV file into the table:

BULK INSERT ZipCode
FROM ‘C:\zipcodes.txt’
WITH
(
FIELDTERMINATOR = ‘,’,
ROWTERMINATOR = ‘\n’
)
GO

There ya go, you now have a free zip code table of all 42,000+ United States zip codes! Note that you might need to change the commas and ‘ ‘ marks; sometimes these characters are formatted differently when posted on the web and it can cause havoc in SQL because SQL does not recognize the characters. Just be prepared to change them!

-Flea#