Je suis en train de télécharger un fichier Excel
à une base de données SQL
et fonctionnait très bien sur mon ordinateur, mais une fois que je téléchargé sur le serveur, il me donne cette erreur:Le moteur de base de données Microsoft Jet n'a pas pu trouver l'objet
Exception Details: System.Data.OleDb.OleDbException: The Microsoft Jet database engine could not find the object 'C:\Windows\SysWOW64\inetsrv\Book1.xls'. Make sure the object exists and that you spell its name and the path name correctly.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Voici mon code:
protected void Button1_Click(object sender, EventArgs e) { string excelConnectionString = string.Format("Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0};Extended Properties='Excel 8.0;HRD=YES;IMEX=1'", FileUpload1.PostedFile.FileName); using (OleDbConnection connection = new OleDbConnection(excelConnectionString)) { OleDbCommand command = new OleDbCommand(("Select * FROM [Sheet1$]"), connection); connection.Open(); using (DbDataReader dr = command.ExecuteReader()) { using (SqlBulkCopy bulkCopy = new SqlBulkCopy("Data Source=WSCJTCSQ1;Initial Catalog=TestDB;Persist Security Info=True;User ID=test;Password=test")) { bulkCopy.DestinationTableName = "CoaTest"; bulkCopy.ColumnMappings.Add("First Name", "fName"); bulkCopy.ColumnMappings.Add("Last Name", "lName"); bulkCopy.ColumnMappings.Add("Agency", "agency"); bulkCopy.WriteToServer(dr); } } } Label1.ForeColor = System.Drawing.Color.Red; Label1.Text = "Successfully Uploaded The New Roster"; }
peut u afficher du code qui a sauvé le fichier? Dans quel dossier? –
Lorsque je l'héberge sur ma machine locale, c'est juste sur le bureau. Dois-je d'abord l'enregistrer sur le serveur, puis le retirer à partir de là? – vadim