Using VB.NET
I have the path to my Access file stored in an App.config file:
<add key="constring" value="Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=Data/METL.mdb;Persist Security Info=False"/>
I usually set the connection like this:
'* Get the appSettings constring value (set in the web.config)
strConstring =
System.Configuration.ConfigurationSettings.AppSettings("constring")
'* Connects to database
ocnConnection = New OleDb.OleDbConnection(strConstring)
After creating an Excel file and saving it to a folder other than the
application folder, my database connections always try to find the database
file in the folder the Excel file was saved to.
If dlgSaveFile.ShowDialog() = DialogResult.OK Then
Excel.DisplayAlerts = False
Excel.AlertBeforeOverwriting = False
Excel.ActiveWorkbook.SaveAs(dlgSaveFile.FileName)
Excel.ActiveWorkbook.Close()
Else
Excel.ActiveWorkbook.Close(False)
End If
Thanks,
Sacha
Sacha Korell - 02 Apr 2005 02:54 GMT
I found the solution. After saving, I needed to change the current directory
back to the executing assemblies directory:
Directory.SetCurrentDirectory(System.Reflection.Assembly.GetExecutingAssembly.Location.Substring(0,
System.Reflection.Assembly.GetExecutingAssembly.Location.LastIndexOf("\") +
1))
Thanks,
Sacha
> Using VB.NET
>
[quoted text clipped - 28 lines]
>
> Sacha