Click here to Skip to main content
Click here to Skip to main content
Alternative Tip

Tagged as

Go to top

Load all the Country Names of the World in DropDown

, 7 May 2011
Rate this:
Please Sign up or sign in to vote.
Step1.Downlo...
Step1.
Download coma separated .CSV country file.
Step2.
Create new table for country
suppose CountryId,Country are their fields.
USE TestData
GO
CREATE TABLE Tbl_COUNTRY
( 
CountryId VARCHAR(40),
Country VARCHAR(40)
)
GO
Step3.
Now run following script to load all the data from CSV to database table
BULK
INSERT Tbl_COUNTRY
FROM 'c:\country_data.csv'
WITH
(
FIELDTERMINATOR = ',',
ROWTERMINATOR = '\n'
)
GO
 
Step4.
protected void Page_Load(object sender, EventArgs e)
 {
        
        ddlLocation.DataSource = LoadCountryData() as DataTable;
        ddlLocation.DataTextField = "Country";
        ddlLocation.DataValueField = "CountryId";
        ddlLocation.DataBind();
 }
 
Download countrylist.csv
countrylist.txt[^]
coutrylist.csv[^]

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

ambarishtv
Software Developer
India India





Hi I' Ambarish from India. I've three and half year of experience in application
development solutions.

Educational Qualification

MCA -  from KristuJyoti College of management and technology (MG
University)

B.Sc (Physics) - from NSS College, Changanacherry (MG University)

Skill Set

C#,winforms,asp.net,MVC 3, Java,Design Patterns,VB, Android,JQuery Mobile,SQL,MySqlUML.


Comments and Discussions

 
GeneralHi Anil. countrylist.csv file column has unsupported data fo... Pinmemberambarishtv7-May-11 22:01 
GeneralWhen I run the following BULK INSERT Tbl_COUNTRY FROM 'C:\\c... PinmemberAnil Srivastava7-May-11 10:16 
GeneralThank You Pinmemberambarishtv3-May-11 4:01 
General5 for giving the link .. Now it became a complete solution. PinmemberPrasanta_Prince3-May-11 4:00 
GeneralReason for my vote of 5 Good solution after giving the CSV l... PinmemberPrasanta_Prince3-May-11 3:59 
Generalthank you for suggestion http://www.floresense.com/resc_cent... Pinmemberambarishtv2-May-11 20:05 
GeneralRe: Hi Anil. countrylist.csv file column has unsupported data fo... Pinmemberambarishtv7-May-11 22:00 
GeneralProvide the link to download CSV file. PinmemberPrasanta_Prince1-May-11 6:09 
GeneralRe: When I run the following BULK INSERT Tbl_COUNTRY FROM 'C:\... PinmemberAnil Srivastava7-May-11 10:15 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Mobile
Web01 | 2.8.140926.1 | Last Updated 8 May 2011
Article Copyright 2011 by ambarishtv
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid