Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / April 2005

Tip: Looking for answers? Try searching our database.

Data path changes after saving files with SaveFileDialog

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Microsoft News Server - 01 Apr 2005 21:52 GMT
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

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.