Results 1 to 13 of 13
  1. #1
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Problems connecting to database

    I can't remember how to do this with ASP Classic, so I probably cannot help you with ASP.Net. However, I do recall thinking that for performance reasons, it would be best to run the ADO components on the same box with the database. Otherwise, gigantic loads of data need to be passed from the database file server to the code actually performing queries. But that doesn't answer your question.

    Can you open the database on the network directly in Access? Assuming your Windows credentials should permit that, might there be a .mdw security file that needs also to be copied to the server?

  2. #2
    Platinum Lounger
    Join Date
    Feb 2002
    Location
    A Magic Forest in Deepest, Darkest Kent
    Posts
    5,681
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Problems connecting to database

    Alan

    <img src=/S/crossfingers.gif border=0 alt=crossfingers width=17 height=16> This will work as the Access 97 thing is worrying me a bit ( I don't know why, but it is!!!!)

    Have you tried this:


    <Script Runat= "Server">

    Sub Page_Load ( s as Object, e as EvenArgs )
    Dim conTable as OleDbConnection

    conTable - New OleDbConnection ( "PROVIDER =Microsoft.Jet.OLEDB.4.0;DATA Source =commonfDatabasetables.mdb")

    conTable.Open()
    End Sub

    </Script>

    Fresh out of my super dooper ASP.NET unleashed book <img src=/S/grin.gif border=0 alt=grin width=15 height=15>
    Jerry

  3. #3
    Silver Lounger
    Join Date
    Jan 2001
    Location
    Indianapolis, Indiana, USA
    Posts
    1,862
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Problems connecting to database

    If the other suggestions don't work, try adding Server.MapPath("YourPathHere") to your connection string for the data source argument.

    Be sure to break your string appropriately - i.e. "....................." & Server.MapPath(".....mdb") & "....."

  4. #4
    3 Star Lounger
    Join Date
    Apr 2001
    Location
    Warrington, Cheshire
    Posts
    355
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Re: Problems connecting to database

    Hi guys, had a few days on other projects but back with this:
    Not much progress to report I'm afraid,
    Using the normal pathing:
    The Microsoft Jet database engine cannot open the file 'commonfDatabasetables.mdb'. It is already opened exclusively by another user, or you need permission to view its data

    I have tried both anonymous and non-anonymous setting in IIS.
    With the anonymous I used my own logon to make sure access would be assured but no luck.
    I have checked security settings on the containing folders as well as the database file itself - has Everyone added to all with full control so that .ldb can be created deleted etcetera.
    With Marks suggestion of the server.mappath I get the following error:
    Invalid path for MapPath 'commonf/Database/tables.mdb'. A virtual path is expected.

    Same result with back slashes.

    Should I include the network folder as a virtual folder in my IIS?.....tried and failed, not able to add network virtual directory

  5. #5
    3 Star Lounger
    Join Date
    Apr 2001
    Location
    Warrington, Cheshire
    Posts
    355
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Re: Problems connecting to database

    I now have the database directory as a virtual directory on my IIS.
    But what should the path now be?
    ..databasetables?

    TIA
    Alan
    brrrrrrr Cheshire

  6. #6
    3 Star Lounger
    Join Date
    Apr 2001
    Location
    Warrington, Cheshire
    Posts
    355
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Re: Problems connecting to database

    SUCCESS!!!!
    The virtual directory route bugged me, because I knew it should have been possible given the accessibility of the network folders.
    When trying to make the virtual directory the wizard went through all the motions of connecting to the remote folder, asked for log on, password etcetera, but at the last hurdle - just when you expect to see the little "world" connection icon - I got the stop sign. Major dissapointment.
    But the connection still appeared on my directory list - so Right moused and checked properties.
    In the security tab it had the connection string (commonfdatabase) but when I went to connect it said no go and prompted for logon name/password (which it already had from my anonymous logon).
    Selected OK and applied settings. No dialogue to say it wasn't available or not connected.
    Close properties dialogue and voila....World Icon next to virtual directory.
    Clicked in directory and there's the database "tables.mdb".
    So far so good.
    All that remained was to use the correct path as source:
    OleDbConnection("Provider=Microsoft.Jet.OleDb.4.0; Data Source=9DMG11JManagementReportsDatabasetables.mdb" )

    Just so happens that I used Database as the name on the IIS as well as the remote location.
    Point to note though is that the frst time I used the exact same path, I got errors. With no change to the path and a good half hour later, the connection succeeded.
    I suspect it could have something to do with the indexing service which runs on the server which I know can give server errors. (MS KB 329065)

    Thanks to you guys for the replies and as always it just kind of helps to bounce the ideas around to maintain the creative impetus.

    Just thought I'd share the successful result because for me there's nothing worse than seeing a problem on a forum without the solution.

    Cheers.
    Alan
    Cheshire

  7. #7
    3 Star Lounger
    Join Date
    Apr 2001
    Location
    Warrington, Cheshire
    Posts
    355
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Problems connecting to database-SUCCESS

    Using IIS (5) on local machine.
    aspx pages
    bind a datagrid
    access 97 database in local folder

    All works satisfactorily.

    However, I want the database to be on a shared server and when I try to connect to the new location I get:
    The Microsoft Jet database engine cannot open the file 'commonfDatabasetables.mdb'. It is already opened exclusively by another user, or you need permission to view its data.

    In IIS I have anonymous access enabled and I have disabled the "allow IIS to control password"
    I have used a specific user name and password.
    The specific user name I have given full access to both the database and the containing folder (so .ldb file can be written/modified/destroyed etcetera).

    The connection string for the datasource is:
    Data Source=commonfDatabasetables.mdb
    With this string I get the permissions denied error.

    I have tried the following strings which result in "is not a valid path":
    /commonf/Database/tables.mdb
    /commonfDatabasetables.mdb
    ..commonfDatabasetables.mdb

    Any suggestions would be appreciated but at the moment I'm looking at the solution being to have a copy of the database permanently reside in the web page folder.

    Same problem exists when a table in the database is linked to a table in a network database.

    TIA
    Alan
    Snowy -6C Cheshire

  8. #8
    Platinum Lounger
    Join Date
    Feb 2002
    Location
    A Magic Forest in Deepest, Darkest Kent
    Posts
    5,681
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Problems connecting to database

    <img src=/S/cheers.gif border=0 alt=cheers width=30 height=16>

    Excellent news, thanks for sharing.
    Jerry

  9. #9
    Silver Lounger
    Join Date
    Jan 2001
    Location
    Indianapolis, Indiana, USA
    Posts
    1,862
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Problems connecting to database

    If I understand your post correctly, it sounds like you have created a virtual directory in IIS for your database. If that's the case, that is a major security risk - especially if the IIS permissions are set to anonymous for that folder. Anyone can download your entire database!

    Using a file share on the network is fine as long as it can't be accessed directly through a web path.

    Also, when I worked with classic ASP, I used an include file to store my database connection details. I referenced that #INCLUDE in any page that used the database, rather than having to rewrite the connection string on each page. This is a simple way to keep the connection information in one location.

    Hope this helps...

  10. #10
    3 Star Lounger
    Join Date
    Apr 2001
    Location
    Warrington, Cheshire
    Posts
    355
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Re: Problems connecting to database

    That's right Mark, but at present it is local intranet only and in test area isolated (physically) from external.
    The remaining areas are windows logon authentication and given a few moments I will be looking at taking anon off.
    Thanks for the concerns though.
    The connection file - I use udl's - is that feasible do you think
    Alan

  11. #11
    Silver Lounger
    Join Date
    Jan 2001
    Location
    Indianapolis, Indiana, USA
    Posts
    1,862
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Problems connecting to database

    Alan,

    I still suggest that it's a bad idea to have the folder shared by IIS at all - even if it uses Windows authentication. If you have your connection string properly constructed, you can store the data anywhere that the impersonated IIS user account can read (local or network).

    Can you post some exerpts from your code that show your connection string (as well as a few lines above and below)? Also, please post the UNC path of your database.

  12. #12
    3 Star Lounger
    Join Date
    Apr 2001
    Location
    Warrington, Cheshire
    Posts
    355
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Re: Problems connecting to database

    Hi Mark, sorry for not geting back sooner.
    Following on from your suggestions I was racked with concerns regarding security issues - rightly so as you pointed out.
    After considering the options and risk assessing, the consensus now is to (as suggested very early in post) have the database tables structures (back end) located locally on the IIS.
    The reports work fine and connection is reliable.
    Traffic is up but well within the capabilities of the server - just got to deal with the front end of the db connecting to the server.
    Cheers
    Alan

  13. #13
    Silver Lounger
    Join Date
    Jan 2001
    Location
    Indianapolis, Indiana, USA
    Posts
    1,862
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Problems connecting to database

    Thanks for the update, Alan. It sounds like you're on the right track!

Posting Permissions

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