Click here to Skip to main content
15,887,683 members
Home / Discussions / C#
   

C#

 
AnswerRe: Import and Export Excel Files into SQL with C#2005 ? Pin
Dave Kreskowiak15-Sep-14 1:32
mveDave Kreskowiak15-Sep-14 1:32 
GeneralRe: Import and Export Excel Files into SQL with C#2005 ? Pin
OriginalGriff15-Sep-14 2:14
mveOriginalGriff15-Sep-14 2:14 
GeneralRe: Import and Export Excel Files into SQL with C#2005 ? Pin
Dave Kreskowiak15-Sep-14 10:24
mveDave Kreskowiak15-Sep-14 10:24 
GeneralRe: Import and Export Excel Files into SQL with C#2005 ? Pin
Member 245846716-Sep-14 16:45
Member 245846716-Sep-14 16:45 
GeneralRe: Import and Export Excel Files into SQL with C#2005 ? Pin
Dave Kreskowiak16-Sep-14 18:56
mveDave Kreskowiak16-Sep-14 18:56 
GeneralRe: Import and Export Excel Files into SQL with C#2005 ? Pin
Member 245846717-Sep-14 15:58
Member 245846717-Sep-14 15:58 
GeneralRe: Import and Export Excel Files into SQL with C#2005 ? Pin
Dave Kreskowiak17-Sep-14 17:09
mveDave Kreskowiak17-Sep-14 17:09 
AnswerRe: Import and Export Excel Files into SQL with C#2005 ? Pin
Member 245846716-Sep-14 23:24
Member 245846716-Sep-14 23:24 
I am be an error importing the Excel2007: "Not a legal OleAut date", you see my code below:

C#
public static void ImportToSql(string excelfilepath)
        {
            string ssqltable = "TABHD";
            string myexceldataquery = "SELECT * FROM [dbo_TABHD]";
            try
            {
                string sexcelconnectionstring = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source =" + excelfilepath + "; Extended Properties=\"Excel 12.0; HDR=Yes; IMEX=2\"";
                string ssqlconnectionstring = @"server = itfriend;Database=HD;integrated security = true";

                //execute a query to erase any previous data from our destination table
                string sclearsql = "delete " + ssqltable;
                INSERTING IT.INSTEAD I WANT TO UPDATE TABLE DATA"
                SqlConnection sqlconn = new SqlConnection(ssqlconnectionstring);                

                OleDbConnection oledbconn = new OleDbConnection(sexcelconnectionstring);
                OleDbCommand oledbcmd = new OleDbCommand(myexceldataquery, oledbconn);
                oledbconn.Open();
                OleDbDataReader dr = oledbcmd.ExecuteReader();
                SqlBulkCopy bulkcopy = new SqlBulkCopy(ssqlconnectionstring);
                bulkcopy.DestinationTableName = ssqltable;

                bulkcopy.WriteToServer(dr);

                Console.WriteLine(".xlsx file imported succssessfully into database.", bulkcopy.NotifyAfter);
                oledbconn.Close();
            }
            catch (Exception ex)
            {
                //handle exception
                MessageBox.Show(ex.Message.ToString(), "Warning !");
            }
        }

GeneralRe: Import and Export Excel Files into SQL with C#2005 ? Pin
Dave Kreskowiak17-Sep-14 17:10
mveDave Kreskowiak17-Sep-14 17:10 
GeneralRe: Import and Export Excel Files into SQL with C#2005 ? Pin
Member 245846717-Sep-14 23:47
Member 245846717-Sep-14 23:47 
GeneralRe: Import and Export Excel Files into SQL with C#2005 ? Pin
Dave Kreskowiak18-Sep-14 1:45
mveDave Kreskowiak18-Sep-14 1:45 
GeneralRe: Import and Export Excel Files into SQL with C#2005 ? Pin
Member 245846718-Sep-14 18:41
Member 245846718-Sep-14 18:41 
QuestionDraw text on video playing by C# Pin
bonnymon14-Sep-14 20:55
bonnymon14-Sep-14 20:55 
AnswerRe: Draw text on video playing by C# Pin
Pete O'Hanlon14-Sep-14 21:30
mvePete O'Hanlon14-Sep-14 21:30 
QuestionEncrypted XML File Pin
Jassim Rahma14-Sep-14 19:55
Jassim Rahma14-Sep-14 19:55 
AnswerRe: Encrypted XML File Pin
OriginalGriff14-Sep-14 21:39
mveOriginalGriff14-Sep-14 21:39 
GeneralRe: Encrypted XML File Pin
Jassim Rahma14-Sep-14 21:40
Jassim Rahma14-Sep-14 21:40 
GeneralRe: Encrypted XML File Pin
OriginalGriff14-Sep-14 22:30
mveOriginalGriff14-Sep-14 22:30 
AnswerRe: Encrypted XML File Pin
Bernhard Hiller14-Sep-14 22:45
Bernhard Hiller14-Sep-14 22:45 
QuestionWhich is best for .net C# environment Resharper or Klocwork? Pin
Subha.A14-Sep-14 16:51
Subha.A14-Sep-14 16:51 
AnswerRe: Which is best for .net C# environment Resharper or Klocwork? Pin
CPallini14-Sep-14 18:54
mveCPallini14-Sep-14 18:54 
AnswerRe: Which is best for .net C# environment Resharper or Klocwork? Pin
BillWoodruff14-Sep-14 19:42
professionalBillWoodruff14-Sep-14 19:42 
GeneralRe: Which is best for .net C# environment Resharper or Klocwork? Pin
Pete O'Hanlon14-Sep-14 21:27
mvePete O'Hanlon14-Sep-14 21:27 
QuestionStart Process With Dock Style Pin
Django_Untaken14-Sep-14 10:05
Django_Untaken14-Sep-14 10:05 
AnswerRe: Start Process With Dock Style Pin
Dave Kreskowiak14-Sep-14 11:04
mveDave Kreskowiak14-Sep-14 11:04 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.