| | |
app path adodb vb.net
Please support our VB.NET advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Aug 2007
Posts: 16
Reputation:
Solved Threads: 0
Dear all, as always I am back with yet again a simple question.
I have developed an application in vb.net which has VB interface as front end and access 2003 as backend. The application path which I setup initially is :
here the access file is refering to C drive however, I want it to be within Application folder so that when I create the application, the file should be installed and ran directly from the application directory and not from C drive.
I have added the file into the compilation and it created the application (exe) fine however when I install the program and run it, it asks for the C:\Lensesdb.mdb file (says its missing) whereas the application file is within application folder.
I have found few ways online:
1st Example
2nd Example
I did bring them into my coding but I don't know how to refer to my application path when I type
how can I declare the the path so that I don't have to manually put it into the C drive of destination pc each time I install the application.
I hope I made some sense here
Regards
J
I have developed an application in vb.net which has VB interface as front end and access 2003 as backend. The application path which I setup initially is :
VB.NET Syntax (Toggle Plain Text)
Dim MyConn As ADODB.Connection MyConn = New ADODB.Connection MyConn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source= C:\Lensesdb.mdb;" MyConn.Open()
here the access file is refering to C drive however, I want it to be within Application folder so that when I create the application, the file should be installed and ran directly from the application directory and not from C drive.
I have added the file into the compilation and it created the application (exe) fine however when I install the program and run it, it asks for the C:\Lensesdb.mdb file (says its missing) whereas the application file is within application folder.
I have found few ways online:
1st Example
VB.NET Syntax (Toggle Plain Text)
Public Function App_Path() As String Return System.AppDomain.CurrentDomain.BaseDirectory() End Function
2nd Example
VB.NET Syntax (Toggle Plain Text)
Private Function GetAppPath() As String Dim i As Integer Dim strAppPath As String strAppPath = System.Reflection.Assembly.GetExecutingAssembly.Location() i = strAppPath.Length - 1 Do Until strAppPath.Substring(i, 1) = "\" i = i - 1 Loop strAppPath = strAppPath.Substring(0, i) Return strAppPath End Function
I did bring them into my coding but I don't know how to refer to my application path when I type
VB.NET Syntax (Toggle Plain Text)
MyConn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source= C:\Lensesdb.mdb;"
how can I declare the the path so that I don't have to manually put it into the C drive of destination pc each time I install the application.
I hope I made some sense here

Regards
J
Hi
Try Application.StartupPath, It Gets the path for the executable file that started the application, not including the executable name.
Your Code might be
Try Application.StartupPath, It Gets the path for the executable file that started the application, not including the executable name.
Your Code might be
VB.NET Syntax (Toggle Plain Text)
MyConn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source= " & Application.StartupPath & "\Lensesdb.mdb;"
KSG
•
•
Join Date: Aug 2007
Posts: 16
Reputation:
Solved Threads: 0
Morning selvaganapathy,
I have tried your method however it didn't work. When I install the application and run it on a client machine it still comes up with the error message saying that the file cannot be found under C:\Lensesdb.mdb. However, When I put the file there it works absolutely fine.
I am using Visual Studio 2005 built in Setup Wizard to create setup file and yes I have added the mdb file while adding other files for the application. This though has not made any difference.
any other suggestion will be welcomed.
Many thanks
Regards
J
I have tried your method however it didn't work. When I install the application and run it on a client machine it still comes up with the error message saying that the file cannot be found under C:\Lensesdb.mdb. However, When I put the file there it works absolutely fine.
I am using Visual Studio 2005 built in Setup Wizard to create setup file and yes I have added the mdb file while adding other files for the application. This though has not made any difference.
any other suggestion will be welcomed.
Many thanks
Regards
J
•
•
Join Date: Aug 2007
Posts: 16
Reputation:
Solved Threads: 0
Morning selvaganapathy,
The only place I can see it is declared as C:\lensesdb.mdb is under the config file and under settings.designer.vb Here is the sample code of the config file and the settings.designer.vb.
app.config
------------
Settings.designer.vb
-----------------------
what should I do to that line where it says C:\Lensesdb.mdb? Shall I delete it? or shall i change it?
I have tried changing it to " &application......... " but it didn't work, though when I typed ..........Datasource=/Lensesdb.mdb" it didnt give me any errors.
whats your thoughts on that?
I'd like to thank you for your ongoing help however, if you help me little bit more I am sure I can achieve my goal
many thanks
Regards
J
The only place I can see it is declared as C:\lensesdb.mdb is under the config file and under settings.designer.vb Here is the sample code of the config file and the settings.designer.vb.
app.config
------------
VB.NET Syntax (Toggle Plain Text)
<?xml version="1.0" encoding="utf-8" ?> <configuration> <configSections> </configSections> <connectionStrings> <add name="clLabApp.My.MySettings.LensesdbConnectionString" connectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Lensesdb.mdb" providerName="System.Data.OleDb" /> </connectionStrings> <system.diagnostics> <sources> <!-- This section defines the logging configuration for My.Application.Log --> <source name="DefaultSource" switchName="DefaultSwitch"> <listeners> <add name="FileLog"/> <!-- Uncomment the below section to write to the Application Event Log --> <!--<add name="EventLog"/>--> </listeners> </source> </sources> <switches> <add name="DefaultSwitch" value="Information" /> </switches> <sharedListeners> <add name="FileLog" type="Microsoft.VisualBasic.Logging.FileLogTraceListener, Microsoft.VisualBasic, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" initializeData="FileLogWriter"/> <!-- Uncomment the below section and replace APPLICATION_NAME with the name of your application to write to the Application Event Log --> <!--<add name="EventLog" type="System.Diagnostics.EventLogTraceListener" initializeData="APPLICATION_NAME"/> --> </sharedListeners> </system.diagnostics> </configuration>
Settings.designer.vb
-----------------------
VB.NET Syntax (Toggle Plain Text)
<Global.System.Configuration.ApplicationScopedSettingAttribute(), _ Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _ Global.System.Configuration.SpecialSettingAttribute(Global.System.Configuration.SpecialSetting.ConnectionString), _ Global.System.Configuration.DefaultSettingValueAttribute("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Lensesdb.mdb")> _ Public ReadOnly Property LensesdbConnectionString() As String Get Return CType(Me("LensesdbConnectionString"),String) End Get End Property End Class End Namespace
what should I do to that line where it says C:\Lensesdb.mdb? Shall I delete it? or shall i change it?
I have tried changing it to " &application......... " but it didn't work, though when I typed ..........Datasource=/Lensesdb.mdb" it didnt give me any errors.
whats your thoughts on that?
I'd like to thank you for your ongoing help however, if you help me little bit more I am sure I can achieve my goal

many thanks
Regards
J
Last edited by jaytheguru; Jun 25th, 2008 at 5:19 am.
•
•
Join Date: Jun 2008
Posts: 7
Reputation:
Solved Threads: 0
I think you have added the mdb file in the Setup wizard from C:\. First add the mdb file to your folder and hen you can use the Application.Startup properly as stated above. Then use the Setup Wizard to create the Setup files. This should solve the problem.
![]() |
Similar Threads
- How do I use Access data for a Word document? (Visual Basic 4 / 5 / 6)
Other Threads in the VB.NET Forum
- Previous Thread: How to get freelancing software projects to work from home - Please Help
- Next Thread: opening a new project
| Thread Tools | Search this Thread |
.net .net2008 2008 access advanced application array basic beginner browser button buttons center click client code combo convert cuesent data database datagrid datagridview date datetimepicker designer dissertation dissertations dissertationtopic eclipse excel exists fade filter forms function generatetags html images input intel internet listview map mobile module monitor msaccess net number objects open panel pdf picturebox picturebox2 port position print printing problem read regex remove right-to-left save search searchvb.net select serial settings shutdown socket sqldatbase sqlserver survey temperature textbox timer timespan transparency txttoxmlconverter user usercontol vb vb.net vba vbnet visual visualbasic visualbasic.net visualstudio.net visualstudio2008 web winforms winsock wpf wrapingcode xml year





