Excel to sqlserver
-
Hi, I have excel files where the teachers include student marks. Excel files have these columns: Id_Student ____libelle_matter1____libelle_matter2 how to import these files to table review(Id_Student,id_matter,marks) I have the table matter: (id_matter, libelle_matter,coeff)?? Thanks.
-
Hi, I have excel files where the teachers include student marks. Excel files have these columns: Id_Student ____libelle_matter1____libelle_matter2 how to import these files to table review(Id_Student,id_matter,marks) I have the table matter: (id_matter, libelle_matter,coeff)?? Thanks.
Use import/export wizard of SQL server(http://msdn.microsoft.com/en-us/library/ms140052.aspx[^]). There's a feature there where you can map the fields from your excel spreadsheet to the fields of your table.
-
Use import/export wizard of SQL server(http://msdn.microsoft.com/en-us/library/ms140052.aspx[^]). There's a feature there where you can map the fields from your excel spreadsheet to the fields of your table.
-
Hi,thanks walterhevedeich I want the teacher clicks on a button to send the files ,import/export wizard is manually, right?
Here is the C#.NET code... // Connection String to Excel Workbook string excelConnectionString = @"Provider=Microsoft .Jet.OLEDB.4.0;Data Source=Book1.xls;Extended Properties=""Excel 8.0;HDR=YES;"""; // Create Connection to Excel Workbook using (OleDbConnection connection = new OleDbConnection(excelConnectionString)) { OleDbCommand command = new OleDbCommand ("Select ID,Data FROM [Data$]", connection); connection.Open(); // Create DbDataReader to Data Worksheet using (DbDataReader dr = command.ExecuteReader()) { // SQL Server Connection String string sqlConnectionString = "Data Source=.; Initial Catalog=Test;Integrated Security=True"; // Bulk Copy to SQL Server using (SqlBulkCopy bulkCopy = new SqlBulkCopy(sqlConnectionString)) { bulkCopy.DestinationTableName = "ExcelData"; bulkCopy.WriteToServer(dr); } } }