ahmed salah

ahmed salah

  • NA
  • 85
  • 58.8k

How to create connection string to excel sheet 2007 by C#

Feb 28 2017 5:07 AM
I need to know are this connection string to excel is wrong or true

  1. public static  string  fileName = string.Format("{0}\\Book502", Directory.GetCurrentDirectory());  
  2. string connection = string.Format("Provider=Microsoft.ACE.OLEDB.12.0;" + "Data Source={0};Mode=ReadWrite;Extended Properties='Excel 12.0 Xml;HDR=YES'", fileName);  


my file book 502
have two sheets

sheet 1

i insert data and update and read data from it

it have following column

ID INTEGER

User Name char(255)

Country char(255)

sheet 2
 
have following columns

ID INTEGER

Member Name char(255)

meaning all two sheets have text except ID

ALSO file have column in header

processes of two sheets insert update read select

size of transaction i will use 5000 rows

3 USER will use excel sheet

so that what correct format to excel file ?

the format i write working good ?
but really i need what i assign IMEX=0 or 1 or 2
HDR = YES OR NO

Answers (6)