shingo99 Posted December 27, 2004 Posted December 27, 2004 hi can i know how to make app.path that is normally use in VB6 into VB.Net coding? Data Source=C:\Documents and Setting\VB.Net\bin\cinema.mdb this code is currently how i connect to my database but when i move my program to other computer i will have to reset it again so can teach me how to make it to app.path or something similiar thank you in advance Quote
Administrators PlausiblyDamp Posted December 27, 2004 Administrators Posted December 27, 2004 Application.ExecutablePath is probably the one you are after. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
shingo99 Posted December 27, 2004 Author Posted December 27, 2004 Application.ExecutablePath is probably the one you are after. how do i do this Application.ExecutablePath? im sort of new to this VB.Net coding i tried..but error keep coming Data Source=Application.ExecutablePath\VB.Net\bin\cinema.mdb am i doing this correctly? Quote
coldfusion244 Posted December 27, 2004 Posted December 27, 2004 (edited) how do i do this Application.ExecutablePath? im sort of new to this VB.Net coding i tried..but error keep coming Data Source=Application.ExecutablePath\VB.Net\bin\cinema.mdb am i doing this correctly? [CS] DataSource = Application.ExecutablePath + "\\cinema.mdb"; [/CS] DataSource = Application.ExecutablePath + "\\cinema.mdb" VB.net and C# just incase. You have a space in your variable name and you must tell it to append the new text on the end of Application.ExecutablePath. I don't know why you are adding \bin and such to it, as the executable file should already be in the bin directory. Edited December 27, 2004 by coldfusion244 Quote -Sean
VbStudent302 Posted November 30, 2005 Posted November 30, 2005 for vb.net your going to want to use : DataSource = Application.StartupPath + "\cinema.mdb" instead of: DataSource = Application.ExecutablePath + "\cinema.mdb" Quote
Cags Posted November 30, 2005 Posted November 30, 2005 As VbStudent302 suggested Application.StartupPath is the way to go. By using Application.ExecutablePath you are returning the path complete with application name, which would essentially be telling it to do something like this.... C:\Documents and Setting\VB.Net\bin\application.exe\cinema.mdb instead of C:\Documents and Setting\VB.Net\bin\cinema.mdb On a side note I'm sure when I tried to use StartupPath when launching an application from a shortcut rather than direct from the exe I encountered some problems. It was probably almost a year ago now and after a quick test I can't emulate it, but I'm sure it used to return the path to the shortcut rather than the exe, was this changed in a newer version of the framework or did I just imagine it. Quote Anybody looking for a graduate programmer (Midlands, England)?
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.