Click here to Skip to main content
15,887,974 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello everyone
I have created a Project in VB.Net and Microsoft Access 2007 as database. I have the following code to connect to the database
<br />
Imports System.Data.OleDb<br />
Module connection<br />
    Dim dbPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) & _<br />
        "\digimate.accdb"<br />
    Public Con As OleDbConnection = New OleDbConnection("Provider=Microsoft.Ace.OLEDB.12.0;Data Source=" & dbPath)<br />
    Public Dad As OleDbDataAdapter<br />
    Public Drd As OleDbDataReader<br />
    Public Cmd As OleDbCommand<br />
    Public Dst = New DataSet<br />
    Public CurrentRow As Integer<br />
    Public acno As Integer<br />
End Module<br />
<br />


Now, I just wanted to create a setup for the project but I think I am missing something as a result it is not working as expected.
Please, help in this regard or if any video is available for Setup in VB.Net 2012 with access database.
Thank you
Sarfaraz
Posted
Updated 22-Jan-15 5:22am
v7
Comments
CHill60 22-Jan-15 11:02am    
Have you copied the access database into the correct folder?
sarfarazbhat 22-Jan-15 11:13am    
Sir
After creating the setup i copy the database file to my documents folder of the target machine.
CHill60 22-Jan-15 11:35am    
So what do you mean by "not working as expected"? By the way it's a good idea to use Path.Combine when constructing paths
sarfarazbhat 23-Jan-15 10:47am    
Sir
The project is working fine now after copying all files of bin folder to output files.but now it is displaying the following error during opening reports
Could not load the assembly Microsoft.report viewer.winform....... Or one of its dependencies. The system can not find the file specified.
CHill60 23-Jan-15 11:15am    
You'll need to include REport Viewer[^] as a pre-requisite (and in) your set up package

1 solution

A summary of where we are so far...

- You made sure the access database and the contents of the bin folder had all made their way to the target machine.

- You then got an error "Could not load the assembly Microsoft.ReportViewer.Winforms so you installed Report Viewer[^] but you are still getting the error...

Try ...

1. In your Visual Studio project make sure you have added references for both Microsoft.ReportViewer.WinForms AND Microsoft.ReportViewer.Common

2. In Solution Explorer click on the reference for Microsoft.ReportViewer.Winforms (you may need to click the Show All Files button to get it visible in the explorer)

3. In the Properties Window (Hit F4 if it is not visible) look for property Copy Local and set it to True. This will ensure that the appropriate DLL(s) are copied to your bin folder

4. Repeat steps 2 and 3 above for Microsoft.ReportViewer.Common

5. Rebuild your project and include everything from the Bin folder in your setup
 
Share this answer
 
Comments
sarfarazbhat 25-Jan-15 3:47am    
Thank you so much sir for your kind help.
After following your steps I am now able to view the reports on the target machine but one issue is there that the reports are empty because of the wrong database path.
How can I set the database path for the datasets as dynamic with environment. Getfolderpath as above.
Thank you sir
CHill60 26-Jan-15 7:39am    
Your dbPath seems fine - make sure you are copying the database to the correct folder during your install - remember you may not be installing under the same Username as you are running under.
Alternatively copy the database to C:\ProgramData\YourApplication if you want to share the data across users
sarfarazbhat 4-Feb-15 7:05am    
Sorry for a late reply was out of town.
Sir i am not able to find the location of Program data with

Environment.SpecialFolder.ProgramFilesX86

Do i need to create the ProgramData folder manually and copy the database in it.
CHill60 4-Feb-15 7:15am    
Don't put dynamic data into the Program Files folder - users will not have permissions to update the database (and in some cases will not be able to read it) - they will get a copy of it stored under their profile - this can lead to issues when you update it.
You should be using a sub-folder of Environment.SpecialFolder.ApplicationData and you get get InstallShield to create the folder if it doesn't already exist
sarfarazbhat 4-Feb-15 7:38am    
if i try like

Dim dbPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & _
"\digimate.accdb"


i Get the following error
Could not find file 'C:\Users\COMPAQ\AppData\Roaming\digimate.accdb'.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900