Results 1 to 13 of 13

Thread: [RESOLVED] Access database in VB.Net setup that is writeable in Windows 7

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    May 2004
    Location
    South Charleston, WV, USA
    Posts
    607

    Resolved [RESOLVED] Access database in VB.Net setup that is writeable in Windows 7

    I have a VB.Net program which reads and writes to an Access database. I am trying to deploy the program using a setup (created with INNO Setup). Upon installation on a Windows 7 computer, Windows 7 is preventing it from writing data without changing the permission settings. It reads data but it doesn't write data. This problem doesn't happen in Windows XP. My question is: is there any way to make the Visual Basic .Net program write data to an Access database on Windows 7 from the setup without the user having to change permission settings?

  2. #2
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: Access database in VB.Net setup that is writeable in Windows 7

    Put the access database into the user data folder... I'm guessing you deployed the file to the same folder as where the app is installed (like Program Files) ... right? Starting with Win7, things are locked down in the Program Files folder... it's no longer a reliable place to be writting data... try searching the forums for "|Data|" ... include the pipe symbol... it should turn up a lot of examples on how to use it.

    In short, the path to the database file should be "Database=|Data|\myaccessfile.msdb" or something along those lines. When you deploy it (and I don't know how to do this in INNO) it needs to be moved to the user's app data folder.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    May 2004
    Location
    South Charleston, WV, USA
    Posts
    607

    Re: Access database in VB.Net setup that is writeable in Windows 7

    Thanks for responding.

    I don't understand. Shouldn't that be "Database=|Data|\App_data\myaccessfile.msdb" ?

    This is what I'm using

    Code:
        Public connSTR As String = _
     "Provider=Microsoft.Jet.OLEDB.4.0;User ID=;Password=;Data Source=|DataDirectory|\TransActionsDB.mdb"
    and the database is placed in the application's root folder in Program Files when it gets to Win 7. INNO setup can put it wherever, I think. Is |Data| the same as |DataDirectory| ?
    Last edited by projecttoday; Jul 15th, 2011 at 10:50 AM.

  4. #4
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: Access database in VB.Net setup that is writeable in Windows 7

    yes... DataDirectory is right... but... that's still not the same as the app's root folder, which is where you are installing it. What you could do is check to see if the file exists in the data directory first, if it doesn't exist, COPY it from the app folder to the Data Directory, then you should be able to connect to it from there. That way, also you don't need to make changes to the install, and if the database gets deleted for what ever reason, the app can copy a new one and won't crash.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    May 2004
    Location
    South Charleston, WV, USA
    Posts
    607

    Re: Access database in VB.Net setup that is writeable in Windows 7

    I'm looking through some of the posts here on |DataDirectory|
    DataDirectory is right... but... that's still not the same as the app's root folder
    Can you explain?
    Can I just add a subfolder and put the database there? If this subfolder resides in the Program Files application main folder, wouldn't it be subject to the same permission restrictions (on Windows 7)? I know I said INNO setup will copy the database anywhere but I'm not sure if it will create a new folder.

  6. #6
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: Access database in VB.Net setup that is writeable in Windows 7

    "If this subfolder resides in the Program Files application main folder, wouldn't it be subject to the same permission restrictions (on Windows 7)?" -- no because it doesn't exist in the Programs Folder... it resides in
    C:\users\yourusername\apps\data\another folder\somewhere around here....

    if it's installed for everyone, then instead of being in yourusername, it'll go into the "all users" one.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  7. #7

    Thread Starter
    Fanatic Member
    Join Date
    May 2004
    Location
    South Charleston, WV, USA
    Posts
    607

    Re: Access database in VB.Net setup that is writeable in Windows 7

    I think in VB.Net it does go in the same folder.

  8. #8
    Karen Payne MVP kareninstructor's Avatar
    Join Date
    Jun 2008
    Location
    Oregon
    Posts
    6,714

    Re: Access database in VB.Net setup that is writeable in Windows 7

    If the user has MS-Access 2007+ installed then more one consideration is MS-Access Trust Center which will not throw an exception/error when you attempt to do a update or insert query against a ms-access database via your code in .net.

    http://office.microsoft.com/en-us/wo...010031999.aspx

  9. #9

    Thread Starter
    Fanatic Member
    Join Date
    May 2004
    Location
    South Charleston, WV, USA
    Posts
    607

    Re: Access database in VB.Net setup that is writeable in Windows 7

    Have you worked with Access 2007 databases and setup? I have Access 2007 on my computer but I saved it as Access 2003 for this project. (Why tempt fate?)

  10. #10
    Karen Payne MVP kareninstructor's Avatar
    Join Date
    Jun 2008
    Location
    Oregon
    Posts
    6,714

    Re: Access database in VB.Net setup that is writeable in Windows 7

    Quote Originally Posted by projecttoday View Post
    Have you worked with Access 2007 databases and setup? I have Access 2007 on my computer but I saved it as Access 2003 for this project. (Why tempt fate?)
    Yes but my company/agency uses MSI pushes and set polices via active directory.

    You might like to look that the following

    http://www.access-programmers.co.uk/...d.php?t=136411

    http://bytes.com/topic/access/answer...ue#post2752405

    I do not believe it matters what version you saved it as but instead what version of MS-Access the client has installed.

  11. #11

    Thread Starter
    Fanatic Member
    Join Date
    May 2004
    Location
    South Charleston, WV, USA
    Posts
    607

    Re: Access database in VB.Net setup that is writeable in Windows 7

    This is for an Access deployment. For a Visual Basic program the target computer does not have to have any version of Access installed.

  12. #12
    Karen Payne MVP kareninstructor's Avatar
    Join Date
    Jun 2008
    Location
    Oregon
    Posts
    6,714

    Re: Access database in VB.Net setup that is writeable in Windows 7

    Quote Originally Posted by projecttoday View Post
    This is for an Access deployment. For a Visual Basic program the target computer does not have to have any version of Access installed.
    You should look at the link below which includes links for deployment options
    http://technet.microsoft.com/en-us/l...ffice.12).aspx

  13. #13
    Addicted Member
    Join Date
    Sep 2007
    Location
    Right behind you
    Posts
    170

    Re: Access database in VB.Net setup that is writeable in Windows 7

    this seems like the UAC doing its magic in vista/7

    you need to set this in the app.manifest file

    HTML Code:
    <requestedExecutionLevel level="requireAdministrator" uiAccess="false" />

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width