• 0

[VB.net] Database Connection


Question

How do I create a relative connection a database in VB.net? I want the connection string to always look in the current folder for the database. In ASP.net I use the server.mappath() function to get the current directory. Is there a VB.net equivalent of this? Thanks.

Link to comment
Share on other sites

2 answers to this question

Recommended Posts

  • 0

Check application.startup path. Is that what you want?

it gives u the path of the executable that started the application (file name not included)

Be sure to include a check.. I'm not sure, but I think that if the app is in "c:\myfolder" it does not include the "\" at the end. If it's at the root of the drive ("G:\") it does include the "\". Be sure to take that into account. (not sure, but i think it's like this)

edit: just checked it. if the app is inside a folder, it does not include the final "\".

Link to comment
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.