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); } } }
Sadheesh R
Posts
-
Excel to sqlserver -
Critical decision to be taken by meIs there anyone who can respond to my query. This is bit urgent...Pls help me out...
-
Critical decision to be taken by meHello team, I am in a very critical situation, wherein I will have to take an important decision. I have some existing C programs. Those C programs takes input from .DBF (dBase III) files and .BTR (BTRIEVE) files. I have been given 2 options: 1) Convert .DBF files to .BTR files and .BTR files to .DBF files. These convertion can be done using .NET. If yes, give me some code snippets or some links where I can get the code. 2) Or using .NET is there any other way to replace this BTRIEVE concept itself? In other ways, instead of BTRIEVE, can we go for some other technology? Pls advise....
-
Compiling C programs in VS.NET 2005It is a VC++, Win32 project created in VS.NET 2005 environment. I knew where the header is being read. But the property dbhead.lrecl itself is giving a value of 0. It is just a straight forward property...
-
Compiling C programs in VS.NET 2005I am familiar only with VS.NET environment. I was able to debug and found that dbhead.lrecl property is showing "0". Also I don't have MC6 environment. But I am not able to guess why record length property (dbread.lrecl) is giving "0". If this has some value, then my EXE will work. Any ideas?
-
Compiling C programs in VS.NET 2005I have a C program, which has to be compiled in VS.NET 2005 environment. I don't have any issues with the compilation part and the EXE is generated. When I run the EXE the program is looping. Pls find below the source code: /* ------------------------------------------------------------------------ */ /* Program Name : GLDBACK2.C */ /* Last Modified : 03/11/08 - RMC - Creation date */ /* N.B. GLD0DETL has 190 fields and is 1287 bytes */ /* */ /* ------------------------------------------------------------------------ */ /************************************************************************** */ /* Reads dBase file and outputs as text file. */ /* Based on Valour Software freeware. */ /************************************************************************** */ #include <fcntl.h> #include <sys\types.h> #include <sys\stat.h> #include <io.h> #include <malloc.h> #include <stdio.h> #include <stdlib.h> #include <string.h> typedef struct dbase_head { unsigned char version; /*03 for dbIII and 83 for dbIII w/memo file*/ unsigned char l_update[3]; /*yymmdd for last update*/ unsigned long count; /*number of records in file*/ unsigned int header; /*length of the header *includes the \r at end */ unsigned int lrecl; /*length of a record *includes the delete *byte */ unsigned char reserv[20]; } DBASE_HEAD; typedef struct dbase_fld { char name[11]; /*field name*/ char type; /*field type*/ #define DB_FLD_CHAR 'C' #define DB_FLD_NUM 'N' #define DB_FLD_LOGIC 'L' #define DB_FLD_MEMO 'M' #define DB_FLD_DATE 'D' /* A-T uses large data model but drop it for now */ //char far *data_ptr; /*pointer into buffer*/ unsigned char length;