I have the following code to open an excel sheet
{
OpenFileDialog dlg = new OpenFileDialog(); DialogResult dlgResult = dlg.ShowDialog(); if (dlgResult == DialogResult.OK){
string conString = System.IO.Path.GetFileName(dlg.FileName);}
axMappointControl1.NewMap(MapPoint.
GeoMapRegion.geoMapEurope);MapPoint.
Route route = axMappointControl1.ActiveMap.ActiveRoute; string myConString = @"Provider=Microsoft.Jet.OLEDB.4.0;data source=" ++ conString +
@";Extended Properties=Excel 8.0;";
The code is returning an error for conString, " The name 'conString' does not exist in the current context."
I want to be able to select the excel file from an OpenFileDialog and then use the filename as part of the connection string.
Where am i going wrong with this?
Please help.

Bechir BejaouiRank #144 · 15.9K reputationPosted Jun 28, 2008, 1:14 AM EDT
string conString = ""; and try again
Antony Griffiths7 reputationPosted Jun 28, 2008, 6:20 AM EDT
That sorted it. Thanks.
Sometimes the answers are so simple.