TalkTopics.com - Talk about everything on earth!

Go Back   TalkTopics.com > TalkTopics Community > Computers & Technology > Linux / Open Source

Linux / Open Source Talk about Linux and Open Source stuffs here. On the desktop or as a server, talk all you want and get response from others around the world.

Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old 12-28-2006, 11:44 AM
carlosferns carlosferns is offline
Junior Member
Friendizen
 
Join Date: Dec 2006
Posts: 7
carlosferns is on a distinguished road
Importing excel file into sql server 2000

Well guys thats a very tough job ! If you are not an experienced and are doing this first time in you development career , but trust me its very simple ! Ya , after going through this article and implementing the code written in it you will find it very simple to implement.

Now when you browse other websites they will provide you with the code and tell you to use it directly, but zeeshanjan.com will first tell you some key issues you will come accross during this implementation.When you import the data from the EXCEL to SQL SERVER 2000 then as we have fixed datatypes in SQL SERVER 2000 ,we do not get those in EXCEL .If you have a column containing the text as well as the numeric data , then in this case when the data is imported into SQL SERVER you get text data as NULL.

Well it took a lot of time for me to get this issue resolved but due to ALLAH’s grace i did it at the end.

Well moving on to the concepts directly:



String sConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" +

"Data Source=myexcel.xls";" +

"Extended Properties=’Excel 8.0;HDR=NO;IMEX=1’";



OleDbConnection objConn = new OleDbConnection(sConnectionString);

objConn.Open();

OleDbCommand objCmdSelect = new OleDbCommand("SELECT * FROM myRange1", objConn);

OleDbDataAdapter objAdapter1 = new OleDbDataAdapter();

objAdapter1.SelectCommand = objCmdSelect;

DataSet objDataset1 = new DataSet();

objAdapter1.Fill(objDataset1, "XLData");

This is the connection string you will have to use when importing data from excel into the sql server 2000.Remove the top row containing the header information from the excel file also you need to define the range as myRange1 in the excel worksheet.Select the no. of rows you want to transfer and the click on INSERT--->NAME---->DEFINE

Then specify the range name as the myRange1



The line "Extended Properties=’Excel 8.0;HDR=NO;IMEX=1’";

will help you to resolve the problem of intermixed datatypes in excel.

Now you can use the objDataset1 and trap all the column data in the excel file.........
Reply With Quote
Reply



Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Earn rs.2000 daily.easy form filling jobs for indians. jigarfriend Business Opportunities 0 12-23-2006 06:16 PM
I want to know when a file on my disk was created. hassen1 Apple Macintosh 0 12-19-2006 03:44 PM
Exel, yes microsoft excel sanuanu General Topics 0 11-30-2006 12:49 PM
$2000 car astros99 Classifieds 3 11-08-2006 11:14 PM
Peer2Peer File sharing rabindu General Topics 0 05-30-2006 06:41 PM


All times are GMT +1. The time now is 03:49 AM.





Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0 RC6