Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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

Posted
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?

Posted (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 by coldfusion244
-Sean
  • 11 months later...
Posted

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.

Anybody looking for a graduate programmer (Midlands, England)?

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...