George Laing

George Laing

  • NA
  • 35
  • 0

Problem inserting variable in conn string

Nov 16 2008 9:26 AM

Hi All,
   I seem to be having difficulty inserting a variable in the middle of my connection string. Seems it should be easy enough but I have tried many different ways. I am uploading an excel sheet and at this point have the path hard coded. I want to use a variable for the path. Here is the string.

 string ExcelconnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source= D:\Debug\Draft company_Oilco9.xls;Extended Properties=""Excel 8.0;HDR=YES;""";

Here is what I tried that didn't work

 string ExcelconnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" text";Extended Properties=""Excel 8.0;HDR=YES;""";

Any help is appreciated


Answers (5)