.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

How to import data from Excel to Datagrid

Posted By:      Posted Date: October 22, 2010    Points: 0   Category :Windows Application

I need import data from a Excel file in Datagrid, How can i do?

Can someone give me some example or code (use C#).



View Complete Post

More Related Resource Links

Import excel sheet data to datagrid without using oledb

In my application(C#) i want to import excel sheet to show its data in DatatGridView i dont want to use oledb Need sample code can any any Help

How to import data from WPF DataGrid to Excel?

Hi this is sath chandra.

I have to import data from WPF DataGrid to Excel.

My DataGrid Contais Colors for the paraticular Cell.

I have to import color also to hte excel sheet.........

Thanks and Regards
Sarath Chandra Kanapala

how to import the data of excel into gridview1 using asp.net/c#

i m having excel file a.xlsi m having gridview1,fileupload1how to import excel file from fileupload1 get the destination of a.xls and show the values in gridview1if any boby knows full code answer/mail me at ponmanivannangj@mobiusservices.in

Import Excel data into SQL Server express 2008

I have recently installed SQL express 08 and created a table to import excel data into.  Im running on a windows 7 64 bit OS i5 processor.  I've disabled the firewall (temporarily) and will set the necessary ports once this is working. I run the following query:  (which i found from multiple sources on the net) Select   * From OPENROWSET ( 'Microsoft.Jet.OLEDB.4.0', 'Excel 8.0;Database=C:\Users\Public\lenovoBkup\contacts\outlookFiles\noib2a.xls', 'Select * From [sheet1$]' )  and receive the following message: Msg 7308, Level 16, State 1, Line 1                                                                                  OLE DB provider 'Microsoft.Jet.OLEDB.4.0' cannot be used for distributed queries because the provider is configured to run in single-threaded apartment mode.  (how did they know i was single and living in an apartment? lol) so after research of the following message i restarted the system and relaunched man

Import Excel data into SQL db

 First off sorry if this is in the wrong place but there are over a dozen forum sections here and this seems to be the only one that comes close to what I need.. anyway ... I'm trying to use Visual Web Developer 2008 express to create a form that will allow a user to select an excel file and upload it's values to SQL. I found the following code in another post but as I'm a newbie to C# I'm confused about what 'using' items it needs to run. I keep getting errors like 'System.Web.UI.Page.Application' is a 'property' but is used like a 'type' and "The type or namespace name 'Workbook' could not be found (are you missing a using directive or an assembly reference?)" So what kind of obvious stuff am I overlooking? Or is this just an impossible task for a web app?  1 public DataSet GetExcel(string fileName)2 {3 Application oXL;4 Workbook oWB;5 Worksheet oSheet;6 Range oRng;7 try8 {9 // creat a Application object10 oXL = new ApplicationClass();11 // get WorkBook object12 oWB = oXL.Workbooks.Open(fileName, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value,13 Missing.Value,

How to import Data from Excel to SQL Server Express

 Hi,  please any one is expert in Data Base help me, i would like to import two Data columns from Excel file 2003 instead of two columns in a table in Sql Server Express 2005 , How Can i do that? and what is the way if I have Sql Developer 2005, thank you .  

data type problem in import data from excel file


Dear All,

I am importing the data from excel file using following code.

connstr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath(strFolderFileName) & ";Extended Properties=HTML Import;"
                conn = New OleDbConnection(connstr)
                Dim strSQL As String = "SELECT * FROM [" & strWorkSheetName & "]"

                Dim cmd As New OleDbCommand(strSQL, conn)

                Dim da As New OleDbDataAdapter(cmd)

Now the problem is if a coulmn vlaue start with a number value like "15" then the other string value like "W15" in that column is ignored in the datatable.

eg. The excel column value     Column1


Import and Export List data in excel sheet


Hi ,

I need to import based selective data from excel sheet and export data from sharepoint list, I'm new in Sharepoint.

can anybody guide me? What all possible ways are there and which would be the best.



Import and Export Data (32-bit) Wizard to Dump Data to Excel


I am trying to export some data from a simple three-column table on my SQL 2008 R2 instance to Excel 2007 (also happens in Excel 2003). Our data has a lot of foreign (Hebrew) characters on it and although the copy works ok, the data as it appears in Excel is gibberish.

The source table in SQL contains three columns:

  • smallint - numbers
  • varchar(30) - hebrew text
  • varchar(50) - hebrew text
  • varchar(15) - hebrew text

When I fire up the Import-Export wizard I see the following: http://img524.imageshack.us/img524/1830/sqltable.png. When I click on the yellow warning for a conversion problem, I see this: http://img375.imageshack.us/img375/4255/conversion.png.

Do I need to modify the core SQL or change the data type? I already tried modifying the destination datatype to be varchar instead of LongText but that didn't help.

Any assistance would be fantastic!


Import Excel file with Data Connection into SSIS


I have got an Excel spreadsheet with a Data Connection that I want to import into SSIS. The problem is that the Data Connection does not seem to run at the time the file is imported, so it only calls "old" data.

How can I set SSIS up to run the Data Connection first, or is there something I need to change in my Excel spreadsheet setup?

When a person opens the Excel file normally, they first need to "Enable" the Data Connection in the Security Settings. Once that is done the data will update immediately. I wonder if that is something I somehow need to change to make it work in SSIS?

SSIS import Excel with Data Connection


Hi guys, I am trying to use SSIS for the first time. What I am hoping to do is set up a scheduled job that will get SSIS to read an Excel spreadsheet on a regular basis and import the data out of it into an SQL Server database. Now my Excel spreadsheet uses a Data Connection to a different source and I want the data to be refreshed before SSIS imports it. Is that possible?

The problem I am facing right now is that the Data Connection does not seem to run before SSIS import the data. It keeps importing the old data that was sitting in the Excel spread sheet at the time it was saved last.

Is there any way I can tell SSIS to run the data connection first? Or is there something I need to do in my Excel file to ensure the connection is run?

By the way: the Excel file is set up to run the Data Connection immediately when it is opened normally in Excel, but the general user always first has to go into the Security Settings and enable Data Connections.

Thanks for the help!

Import Data from Excel/Access to Sql CE 3.5


Is there any free tool I can use like SSIS I can define column mapping and import data to Sql CE?



Welcome to help me with my open source project at http://code.google.com/p/batch-image-watermark-processor/

How to Import Excel Data into SQL Server 2008(64 bit) Using SQL Query (in Windows Server 2008 64bit

I am developing VB .Net application in Visual Studio 2008(64bit), SQL Server 2008(64bit) and Windows Server 2008(64bit) environment.

I need to import an Excel and Flat files data into SQL Server database using SQL Query. I tried a lot with the following SQL Queries directly with SQL Server Management Studio,

1. SELECT * INTO  dbo.ExcelImportTest FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0','Excel 8.0;Database=D:\PTPLDCT\DCT Test Datasource\DCT_Excel_Test_Sample_1.xls',
'select * from [Sheet1$]')

While executing i got an error as below,

Msg 7403, Level 16, State 1, Line 1
The OLE DB provider "Microsoft.Jet.OLEDB.4.0" has not been registered.

2. I have also tried with MSDASQL provider,

Select * from openrowset('MSDASQL','Driver={Microsoft Excel Driver (*.xls)};
Dbq=DCT_Excel_Test_Sample_1.xls;DefaultDir=D:\PTPLDCT\DCT Test Datasource\', 'Select * from [Sheet1$]')

Then i encountered the following error,

OLE DB provider "MSDASQL" for linked server "(null)" returned message "[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified".
Msg 7303, Level 16, State 1, Line 1
Cannot initialize the data source object of OLE DB provider "MSDASQL" for linked server "(null)".

3. Finally i have tried the Query with Linked Server,

EXEC sp_addlinkedserver @server = '

Import data from excel file to datagridview in vb.net


 Dim DBConnection = New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=E:\vb.net\2210201\new marks analysis system\new database\stu_basic.xls;Extended Properties=""Excel 12.0 Xml;HDR=Yes""")
        Dim SQLString As String = "SELECT TOP 1000 * FROM [Sheet1$]"
        Dim DBCommand = New OleDbCommand(SQLString, DBConnection)
        Dim DBReader As IDataReader = DBCommand.ExecuteReader()
        dg.DataSource = DBReader




i am using this but its doing nothing .

no errors , no data from excel.

whats the problem in it.?

import unstructured data from excel to SQL Server??


I need urgent help with  importing unstructured data from excel to SQL Server

where  columns of sql table are not in first row in the excel sheet

Excel sheet format is like the following

first name  on first row

last name is on second row  and second column B

date on third row and on column D

I will open connection to excel sheet and start copying data into sql Table

please help

Trying to import excel data into dbo schema using odbc connection with sql server


I have written this vb.net code to import an excel spread sheet but need for it to imported into the dbo shema. When I look in the database the table name is me.tablename instead of dbo.tablename.

    Public Sub Main()
        Dim sheetname As String
        excelpath = "S:\Account Management\jkormann\DynamicScoring\GE_Money_MN.xls"
        ServerName = "server"
        DBName = "sf"
        'SchemaName = "dbo"
        InsertedTableName = Dts.Variables("strTableName").Value.ToString
        sheetname = Dts.Variables("strSheet").Value.ToString
        'ImporttoServer(CStr(ExcelPath), CStr(ServerName), CStr(DBName), CStr(SchemaName), CStr(InsertedTableName))
        ImporttoServer(CStr(ExcelPath), CStr(ServerName), CStr(DBName), CStr(InsertedTableName), CStr(sheetname))

        Dts.TaskResult = Dts.Results.Success

SSIS excel data import crashes.


I am importing data from excel files.

When the import get to the last row in the spreadsheet it crashes.

Is there are reason for this?

Mr Shaw
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend