 |
| 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
|
|
|
|

September 15th, 2006, 10:30 PM
|
|
Authorized User
|
|
Join Date: Jun 2006
Posts: 47
Thanks: 0
Thanked 2 Times in 2 Posts
|
|
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.
|
|

September 16th, 2006, 10:58 AM
|
|
Wrox Author
|
|
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
|
|
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.
|
|

September 17th, 2006, 10:30 PM
|
|
Registered User
|
|
Join Date: Sep 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
you can use SQL Server MMC ,help to import the data
|
|

October 5th, 2006, 12:38 AM
|
|
Authorized User
|
|
Join Date: Jun 2006
Posts: 47
Thanks: 0
Thanked 2 Times in 2 Posts
|
|
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.
|
|

October 5th, 2006, 07:19 AM
|
|
Wrox Author
|
|
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
|
|
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.
|
|

October 5th, 2006, 10:52 PM
|
|
Authorized User
|
|
Join Date: Jun 2006
Posts: 47
Thanks: 0
Thanked 2 Times in 2 Posts
|
|
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.....
|
|

October 5th, 2006, 11:31 PM
|
|
Wrox Author
|
|
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
|
|
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.
|
|

October 7th, 2006, 12:45 AM
|
|
Authorized User
|
|
Join Date: Jun 2006
Posts: 47
Thanks: 0
Thanked 2 Times in 2 Posts
|
|
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.
|
|
 |