Wrox Programmer Forums
|
ASP.NET 1.0 and 1.1 Professional For advanced ASP.NET 1.x coders. Beginning-level questions will be redirected to other forums. NOT for "classic" ASP 3 or the newer ASP.NET 2.0 and 3.5
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 15th, 2006, 10:30 PM
Authorized User
 
Join Date: Jun 2006
Posts: 47
Thanks: 0
Thanked 2 Times in 2 Posts
Default Import Excel File to access database

hello everyone.
i have a problem, my requirement is that i have an excel file and i want to import that file to my access database.

the code as below:
strConn = "Provider=Microsoft.Jet.OLEDB.4.0;" +
    "Data Source=" + Server.MapPath(path) ;
OleDbDataAdapter myCommand =
new OleDbDataAdapter("SELECT * FROM [Sheet1$]",strConn);

DataSet myDataSet = new DataSet();
myCommand.Fill(myDataSet, "ExcelInfo");
DataGrid1.DataSource = myDataSet.Tables["ExcelInfo"].DefaultView; DataGrid1.DataBind();

but it is giving me error like
Unrecognized database format 'c:\inetpub\wwwroot\IDF\db\Book1.xls'.

wat to do...? pl help me out.its urgent

any help will be appreciated.

Komila :(


__________________
Komila Kalia
Software Developer
Reliance engineering Associates (P) Ltd.
 
Old September 16th, 2006, 10:58 AM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

Have you tried to use an XLS driver as opposed to the OLE driver?

--Stole this from a moderator

I will only tell you how to do it, not do it for you.

Unless, of course, you want to hire me to do work for you.
 
Old September 17th, 2006, 10:30 PM
Registered User
 
Join Date: Sep 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

you can use SQL Server MMC ,help to import the data

 
Old October 5th, 2006, 12:38 AM
Authorized User
 
Join Date: Jun 2006
Posts: 47
Thanks: 0
Thanked 2 Times in 2 Posts
Default

thanks dparsons for ur reply.
no i have not used an xls driver..n i even don knw that driver.
will search it on net.
but if u have then can u pl send that driver.
hope my problem get solved with that.
thnks again.

 
Old October 5th, 2006, 07:19 AM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

The driver should be on the server, you need to change your connection string to something like this:

Provider=MSDASQL; Driver={Microsoft Excel Driver (*.xls)}; DBQ=C:\path\filename.xls;

--Stole this from a moderator

I will only tell you how to do it, not do it for you.
Unless, of course, you want to hire me to do work for you.
 
Old October 5th, 2006, 10:52 PM
Authorized User
 
Join Date: Jun 2006
Posts: 47
Thanks: 0
Thanked 2 Times in 2 Posts
Default

thnks again dparsons but u knw wat....i m gettng a big error.....after using that.
i have used connection string like below:
OdbcConnection cn_excel=new OdbcConnection("Provider=MSDASQL; Driver={Microsoft Excel Driver (*.xls)}; DBQ=C:\test.xls");

hey i have to download some file if yes then which....plz help.....

 
Old October 5th, 2006, 11:31 PM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

What is the error?

--Stole this from a moderator

I will only tell you how to do it, not do it for you.
Unless, of course, you want to hire me to do work for you.
 
Old October 7th, 2006, 12:45 AM
Authorized User
 
Join Date: Jun 2006
Posts: 47
Thanks: 0
Thanked 2 Times in 2 Posts
Default

hi dparsons.
thnks for helping. but with oledb.jet provider only my problem get solved.

code is as below.
strConn = "Provider=Microsoft.Jet.OLEDB.4.0;" +
                                "Data Source=" + Server.MapPath(path) + ";" +
                                "Extended Properties=Excel 8.0;";

with the addition of last line problem get solvd i think.

thnks again.







Similar Threads
Thread Thread Starter Forum Replies Last Post
import from excel to sql database manigandan C# 2 March 5th, 2010 05:34 AM
import excel to access Vision G Access 1 October 15th, 2008 02:12 PM
Import Excel file to back end database ghall202 Access VBA 1 June 7th, 2007 11:56 AM
Impoting Excel file into Access Database using ASP prasanta2expert ASP.NET 1.0 and 1.1 Professional 0 October 5th, 2006 02:39 AM
Import an excel file into access arjunvs Access VBA 1 September 15th, 2004 07:21 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.