deploy with an Access database

gogetsome

Member
Joined
Aug 15, 2005
Messages
7
Programming Experience
Beginner
Hello, Iv'e built my first VB.Net 2.0 winform application and need to deploy it. The application contains an Access database. I have tried to deploy it by right clicking on the solution selecting properties, set the publish setting and used the wizard to publish the app. The IDE said the deployment was successful yet when I try to install the app on a client I get an error that the database cannot be found.

So, how do I ensure that the database will be available for the application and what about deployment to a client that does not have the Access applicaiton installed?
 
When you added the Access database to your VB.NET project, it should've asked you if you wanted to add the database to the project. Hopefully, you chose "Yes" (Visual Studio would have made a copy of the database for itself).
 
Thank you for your reply. No that did not occur so I started over since It is a small app and I'm just learning right now.

I'm still having issues with my app accessing the Access DB for some situations. Currently with my app, I droped a datagridview on a form and it did ask for the DB and then set up a dataset binding source and table adapter. When I run the app after deploying the datagrid is populated with no isues.

My issue is with a listbox and picturebox which I populate with the code below and some other controls I populate when an item is selected from the LBO such as a picture box which gets its image from a string in the DB . It gives the same error as above. It cannot find the DB. In debug mode it does with out issue, only once I deploy It can't find the DB.

I think my issues are with paths to connection strings once I deploy the app.

Here is my code if you have time to help.

'fills LBO
PrivateSub FillPhotoGroup()
Dim CN AsString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Application.StartupPath & "\PhotoDB.mdb"
Dim dsPhotoGroup As DataSet
Dim theSQL AsString
Dim da As OleDb.OleDbDataAdapter
theSQL = "SELECT DISTINCT PhotoGroup from Photos"
da = New OleDb.OleDbDataAdapter(theSQL, CN)
dsPhotoGroup = New DataSet
da.Fill(dsPhotoGroup)
lboPhotoGroup.DataSource = dsPhotoGroup.Tables(0).DefaultView
lboPhotoGroup.DisplayMember = dsPhotoGroup.Tables(0).Columns("PhotoGroup").ToString
EndSub
PrivateSub lboPhotoGroup_Click(ByVal sender AsObject, ByVal e As System.EventArgs) Handles lboPhotoGroup.Click
fillPhotos()
btnNext.Visible = True
btnPrevious.Visible = True
EndSub

'fills some labels
PrivateSub fillPhotos()
Dim CN AsString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Application.StartupPath & "\PhotoDB.mdb"
Dim PhotoGroup AsString = lboPhotoGroup.SelectedValue.item("PhotoGroup")
Dim theSQL AsString
Dim da As OleDb.OleDbDataAdapter
Dim strPictureGroup AsString = PhotoGroup
theSQL = "select id, photoGroup, photoName, photoDate, photoDescription, photoURL from Photos where PhotoGroup = '" & strPictureGroup & "'"
da = New OleDb.OleDbDataAdapter(theSQL, CN)
dsPhotoDBDataSet = New DataSet
da.Fill(dsPhotoDBDataSet)
lblPhotoName.Text = dsPhotoDBDataSet.Tables(0).Rows(curRowIndex).Item("PhotoName")
lblPhotoDate.Text = dsPhotoDBDataSet.Tables(0).Rows(curRowIndex).Item("PhotoDate")
lblPhotoDescription.Text = dsPhotoDBDataSet.Tables(0).Rows(curRowIndex).Item("PhotoDescription")
lblPhotoURL.Text = dsPhotoDBDataSet.Tables(0).Rows(curRowIndex).Item("PhotoURL")
getPhoto()
EndSub


PrivateSub getPhoto()
Dim photo AsString
photo = lblPhotoURL.Text
Dim PhotoPath AsString = Application.StartupPath & "\images\" & photo
pboPhoto.Image = Image.FromFile(PhotoPath)
EndSub
 
I also encountered the same problem... i publish my winforms 2 app using the click once deployment but it didn't include the access database.

How do we add an Access Database to a vb.net 2005 project?
 
I already added the Access Database to my project, right click it in the Solution Explorer and select the property "Always Copy". but during deployment the system cannot find the database though my connection string = Application.StartupPath "\DatabaseName"

Another thing is the system is referencing it in the user's local settings\app\.... why is that?
 
Back
Top