5 Replies - 3811 Views - Last Post: 01 February 2013 - 06:57 AM Rate Topic: -----

#1 alaeddine  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 31-January 13

OleDbException (0x80004005)

Posted 31 January 2013 - 07:36 AM

I'm developpin an aplication to my boss,i get an OleDbException (0x80004005) when i'm trying to implement this code:http://www.dreaminco...&showentry=3238 , so i'm really need a help to solve it, this is the Exception:
fedda$' is not a valid name. Make sure that it does not include invalid characters or punctuation and that it is not too long

Is This A Good Question/Topic? 0
  • +

Replies To: OleDbException (0x80004005)

#2 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 9389
  • View blog
  • Posts: 35,262
  • Joined: 12-June 08

Re: OleDbException (0x80004005)

Posted 31 January 2013 - 07:52 AM

Typically it would help to show us what code you are using.. A quick search of "fedda" turned up nothing in that blog post.
Was This Post Helpful? 0
  • +
  • -

#3 rgfirefly24  Icon User is online

  • D.I.C Lover
  • member icon


Reputation: 282
  • View blog
  • Posts: 1,490
  • Joined: 07-April 08

Re: OleDbException (0x80004005)

Posted 31 January 2013 - 01:21 PM

Did you name the sheet Fedda? because when you're working with Excel and trying to query it your statements go against a sheet name. Try changing it to SELECT * FROM [Sheet1$]
Was This Post Helpful? 0
  • +
  • -

#4 alaeddine  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 31-January 13

Re: OleDbException (0x80004005)

Posted 01 February 2013 - 02:01 AM

i have renamed the sheet Sheet1 but it's still the same Exeception,i have have read about this exception that it's a BOGUE : Le pilote ODBC Excel ignore les paramètres FirstRowHasNames et Header : http://support.micro...om/kb/288343/fr,but i was wondring if there is any solution for this Exception cause i really need it since i'm working in an application on MVC Model , and i have to import the Excel data in my data base,
and when i'm trying to test this code:http://www.dreaminco...&showentry=3238:

Upload Controller


using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Data.OleDb;
using System.Data;




namespace testsmltp.Controllers
{
public class UploadController : Controller
{
public ActionResult Index()
{
return View();
}



[HttpPost]
public ActionResult Index(HttpPostedFileBase excelFile)
{


if (excelFile != null)
{
//Save the uploaded file to the disc.
string savedFileName = "~/UploadedExcelDocuments/" + excelFile.FileName;
excelFile.SaveAs(Server.MapPath(savedFileName));

//Create a connection string to access the Excel file using the ACE provider.
//This is for Excel 2007. 2003 uses an older driver.
var connectionString = string.Format("Provider=Microsoft.ACE.OLEDB.12.0;Data Source={0};Extended Properties=Excel 12.0;", Server.MapPath(savedFileName));

//Fill the dataset with information from the Hoja1 worksheet.
var adapter = new OleDbDataAdapter("SELECT * FROM [Sheet1$]", connectionString);
var ds = new DataSet();
adapter.Fill(ds, "results");
DataTable data = ds.Tables["results"];

//Create a new list of People.
var people = new List<Person>();

for (int i = 0; i < data.Rows.Count - 1; i++)
{
Person newPerson = new Person();
newPerson.Id = data.Rows[i].Field<double?>("Id");
newPerson.Name = data.Rows[i].Field<string>("Name");
newPerson.LastName = data.Rows[i].Field<string>("LastName");
newPerson.DateOfBirth = data.Rows[i].Field<DateTime?>("DateOfBirth");

people.Add(newPerson);
}

return View("UploadComplete", people);
}

return RedirectToAction("Error", "Upload");



}





public ActionResult Error()
{
return View();
}


}
}






i get this Eception:




Erreur du serveur dans l'application '/'.
'Sheet1$' is not a valid name. Make sure that it does not include invalid characters or punctuation and that it is not too long.
Description : Une exception non gérée s'est produite au moment de l'exécution de la requête Web actuelle. Contrôlez la trace de la pile pour plus d'informations sur l'erreur et son origine dans le code.

Détails de l'exception: System.Data.OleDb.OleDbException: 'Sheet1$' is not a valid name. Make sure that it does not include invalid characters or punctuation and that it is not too long.

Erreur source:


Ligne 39 : var adapter = new OleDbDataAdapter("SELECT * FROM [Sheet1$]", connectionString);
Ligne 40 : var ds = new DataSet();
Ligne 41 : adapter.Fill(ds, "results");
Ligne 42 : DataTable data = ds.Tables["results"];
Ligne 43 :


Fichier source : C:\Users\Alaeddine\documents\visual studio 2010\Projects\testsmltp\testsmltp\Controllers\UploadController.cs Ligne : 41

Trace de la pile:


[OleDbException (0x80004005): 'Sheet1$' is not a valid name. Make sure that it does not include invalid characters or punctuation and that it is not too long.]
System.Data.OleDb.OleDbCommand.ExecuteCommandTextErrorHandling(OleDbHResult hr) +1108356
System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS dbParams, Object& executeResult) +247
System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object& executeResult) +189
System.Data.OleDb.OleDbCommand.ExecuteCommand(Commandbehavior behavior, Object& executeResult) +58
System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(Commandbehavior behavior, String method) +162
System.Data.OleDb.OleDbCommand.ExecuteReader(Commandbehavior behavior) +110
System.Data.OleDb.OleDbCommand.System.Data.IDbCommand.ExecuteReader(Commandbehavior behavior) +4
System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, Commandbehavior behavior) +140
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, Commandbehavior behavior) +316
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, String srcTable) +86
testsmltp.Controllers.UploadController.Index(HttpPostedFileBase excelFile) in C:\Users\Alaeddine\documents\visual studio 2010\Projects\testsmltp\testsmltp\Controllers\UploadController.cs:41
lambda_method(Closure , ControllerBase , Object[] ) +180
System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters) +14
System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters) +214
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +27
System.Web.Mvc.<>c__DisplayClass15.<InvokeActionMethodWithFilters>b__12() +55
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation) +253
System.Web.Mvc.<>c__DisplayClass17.<InvokeActionMethodWithFilters>b__14() +21
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodWithFilters(ControllerContext controllerContext, IList`1 filters, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +191
System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) +324
System.Web.Mvc.Controller.ExecuteCore() +106
System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext) +91
System.Web.Mvc.ControllerBase.System.Web.Mvc.IController.Execute(RequestContext requestContext) +10
System.Web.Mvc.<>c__DisplayClassb.<BeginProcessRequest>b__5() +34
System.Web.Mvc.Async.<>c__DisplayClass1.<MakeVoidDelegate>b__0() +19
System.Web.Mvc.Async.<>c__DisplayClass8`1.<BeginSynchronous>b__7(IAsyncResult _) +10
System.Web.Mvc.Async.WrappedAsyncResult`1.End() +62
System.Web.Mvc.<>c__DisplayClasse.<EndProcessRequest>b__d() +48
System.Web.Mvc.SecurityUtil.<GetCallInAppTrustThunk>b__0(Action f) +7
System.Web.Mvc.SecurityUtil.ProcessInApplicationTrust(Action action) +22
System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +60
System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +9
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +9652236
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155




so i'm getting confused if i'll find a solution for that spcially th
Was This Post Helpful? 0
  • +
  • -

#5 andrewsw  Icon User is online

  • It's just been revoked!
  • member icon

Reputation: 3615
  • View blog
  • Posts: 12,442
  • Joined: 12-December 12

Re: OleDbException (0x80004005)

Posted 01 February 2013 - 04:06 AM

I would try with apostrophes SELECT * FROM ['Sheet1$'] and make sure that this sheet name in Excel doesn't have any spaces.
Was This Post Helpful? 0
  • +
  • -

#6 alaeddine  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 31-January 13

Re: OleDbException (0x80004005)

Posted 01 February 2013 - 06:57 AM

it dosn't work with the apostrophes but i find the solution that i have to name the sheet inside the excel document too not just the excel document with sheet1. :bananaman: (it's very funny Exception, i thought that's the probleme of oledb OMG)

thank you very much.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1