Server.MapPath connection string question.

Ask a Question related to ASP Database, Design and Development.

  1. #1

    Default Server.MapPath connection string question.

    I have two sites:

    [url]www.site_A.com[/url] & [url]www.site_A_news.com[/url]

    Site_A is in d:\webs\site_a & uses an Access DB in
    d:\webs\site_a\data\db.mdb

    Site_A_news is in d:\webs\site_a\site_a_news also requires access to
    that Access Database.

    How should I setup the connection string so both webs can share the same
    database?
    Dave Guest

  2. Similar Questions and Discussions

    1. encrypting SQL server connection string in web.config
      In my web.config I am storing a connection string to SQL server, along with password and user name. My goal is to somehow encrypt the string so it...
    2. SQL Server connection string works with IIS 5.1 but not IIS 6 in ASP.NET
      Hello, I have a very simple aspx file that runs on WinXP Pro IIS 5.1 and connects to a SQL Server 2k DB running on a Win2003 Server box. It works...
    3. Passwordless connection string to SQL Server?
      Hi, Crossing over from the Unix world, I am quite stumped at this: how can I specify a DB connection string to SQL Server without 1) putting...
    4. Appication name in SQL Server connection string
      Hi group, Does anyone know how I can pass an application name in my connection string and have it be recognized by SQL Server? I have this...
    5. Connection String to connect to SQL Server Database
      http://www.able-consulting.com/ADO_Conn.htm Brian Staff
  3. #2

    Default Re: Server.MapPath connection string question.

    I assume this is the same server since you didn't say otherwise.
    site_a should continue as is.
    site_a_news should use D:\webs\site_a\data\db.mdb in its connection string.

    A different (likely better) solution would be to move the database to
    d:\database\db.mdb and both site_a and site_a_news can get to it from there.

    MSDE would likely be even better.

    TomB


    "Dave" <1@1.ca> wrote in message
    news:uCjtu%23DOEHA.2780@TK2MSFTNGP09.phx.gbl...
    > I have two sites:
    >
    > [url]www.site_A.com[/url] & [url]www.site_A_news.com[/url]
    >
    > Site_A is in d:\webs\site_a & uses an Access DB in
    > d:\webs\site_a\data\db.mdb
    >
    > Site_A_news is in d:\webs\site_a\site_a_news also requires access to
    > that Access Database.
    >
    > How should I setup the connection string so both webs can share the same
    > database?

    TomB Guest

  4. #3

    Default Re: Server.MapPath connection string question.

    Yes, same server - sorry. And I agree, MSDE would be better, but I do
    not have that option at the moment.

    Right now, I have both setup to use the full path
    D:\webs\site_a\data\db.mdb in their connection strings...

    Any reason why I should NOT do that?

    Why do many example of DSN Less connection strings use Server.MapPath?

    Any performance gains by doing that? Security considerations?



    TomB wrote:
    > I assume this is the same server since you didn't say otherwise.
    > site_a should continue as is.
    > site_a_news should use D:\webs\site_a\data\db.mdb in its connection string.
    >
    > A different (likely better) solution would be to move the database to
    > d:\database\db.mdb and both site_a and site_a_news can get to it from there.
    >
    > MSDE would likely be even better.
    >
    > TomB
    >
    >
    > "Dave" <1@1.ca> wrote in message
    > news:uCjtu%23DOEHA.2780@TK2MSFTNGP09.phx.gbl...
    >
    >>I have two sites:
    >>
    >>[url]www.site_A.com[/url] & [url]www.site_A_news.com[/url]
    >>
    >>Site_A is in d:\webs\site_a & uses an Access DB in
    >>d:\webs\site_a\data\db.mdb
    >>
    >>Site_A_news is in d:\webs\site_a\site_a_news also requires access to
    >>that Access Database.
    >>
    >>How should I setup the connection string so both webs can share the same
    >>database?
    >
    >
    >
    Dave Guest

  5. #4

    Default Re: Server.MapPath connection string question.

    Yes, same server - sorry. And I agree, MSDE would be better, but I do
    not have that option at the moment.

    Right now, I have both setup to use the full path
    D:\webs\site_a\data\db.mdb in their connection strings...

    Any reason why I should NOT do that?

    Why do many example of DSN Less connection strings use Server.MapPath?

    Any performance gains by doing that? Security considerations?



    TomB wrote:
    > I assume this is the same server since you didn't say otherwise.
    > site_a should continue as is.
    > site_a_news should use D:\webs\site_a\data\db.mdb in its connection string.
    >
    > A different (likely better) solution would be to move the database to
    > d:\database\db.mdb and both site_a and site_a_news can get to it from there.
    >
    > MSDE would likely be even better.
    >
    > TomB
    >
    >
    > "Dave" <1@1.ca> wrote in message
    > news:uCjtu%23DOEHA.2780@TK2MSFTNGP09.phx.gbl...
    >
    >>I have two sites:
    >>
    >>[url]www.site_A.com[/url] & [url]www.site_A_news.com[/url]
    >>
    >>Site_A is in d:\webs\site_a & uses an Access DB in
    >>d:\webs\site_a\data\db.mdb
    >>
    >>Site_A_news is in d:\webs\site_a\site_a_news also requires access to
    >>that Access Database.
    >>
    >>How should I setup the connection string so both webs can share the same
    >>database?
    >
    >
    >
    Dave Guest

  6. #5

    Default Re: Server.MapPath connection string question.

    > Right now, I have both setup to use the full path
    > D:\webs\site_a\data\db.mdb in their connection strings...
    >
    > Any reason why I should NOT do that?
    Yes, because when you move to a different server, that folder might not
    exist. And you won't be able to just create a folder on the D: drive of an
    ISP's server.
    > Why do many example of DSN Less connection strings use Server.MapPath?
    Because many people host their sites on remote servers, where they have FTP
    access but not local hard disk access. So if they need to make changes to
    the database, it is certainly much easier to use FTP (which usually starts
    at the same root as the web site) than to request the MDB file from the host
    and then ask them to replace it when you've made your changes.
    > Any performance gains by doing that? Security considerations?
    Performance isn't an issue really, unless you're putting the file onto a
    different physical drive, or a SAN or a NAS, which will perform either
    better or worse than the current hard disk. Choosing a different folder on
    the same drive won't have any impact. Some might argue that there is a
    performance implication in calling server.mappath, but you'd be hard pressed
    to demonstrate a noticeable difference even at high volumes.

    asp.general removed from cross-post list.


    Aaron Bertrand - MVP Guest

  7. #6

    Default Re: Server.MapPath connection string question.

    The downside to having your database within your site, is that a user could
    type in the url to the database and download it.
    [url]http://site_a/data/db.mdb[/url]
    To fix, you can rename the database db.asp

    I think the main reasons for using Server.MapPath are
    a) if it's sample code they don't know where you are going to put it
    b) if you move the site to a new server, or a new directory, the link is
    relative so it won't break.

    Tom B

    "Dave" <1@1.ca> wrote in message
    news:ujWcKNEOEHA.3264@tk2msftngp13.phx.gbl...
    > Yes, same server - sorry. And I agree, MSDE would be better, but I do
    > not have that option at the moment.
    >
    > Right now, I have both setup to use the full path
    > D:\webs\site_a\data\db.mdb in their connection strings...
    >
    > Any reason why I should NOT do that?
    >
    > Why do many example of DSN Less connection strings use Server.MapPath?
    >
    > Any performance gains by doing that? Security considerations?
    >
    >
    >
    > TomB wrote:
    >
    > > I assume this is the same server since you didn't say otherwise.
    > > site_a should continue as is.
    > > site_a_news should use D:\webs\site_a\data\db.mdb in its connection
    string.
    > >
    > > A different (likely better) solution would be to move the database to
    > > d:\database\db.mdb and both site_a and site_a_news can get to it from
    there.
    > >
    > > MSDE would likely be even better.
    > >
    > > TomB
    > >
    > >
    > > "Dave" <1@1.ca> wrote in message
    > > news:uCjtu%23DOEHA.2780@TK2MSFTNGP09.phx.gbl...
    > >
    > >>I have two sites:
    > >>
    > >>[url]www.site_A.com[/url] & [url]www.site_A_news.com[/url]
    > >>
    > >>Site_A is in d:\webs\site_a & uses an Access DB in
    > >>d:\webs\site_a\data\db.mdb
    > >>
    > >>Site_A_news is in d:\webs\site_a\site_a_news also requires access to
    > >>that Access Database.
    > >>
    > >>How should I setup the connection string so both webs can share the same
    > >>database?
    > >
    > >
    > >

    TomB Guest

  8. #7

    Default Re: Server.MapPath connection string question.

    Sorry, forgot about the security implications. Yes, storing it in a hard
    location instead of relative *can* mean that your MDB file is a little more
    secure from prying eyes. However, see [url]http://www.aspfaq.com/2454[/url] for some
    other information.

    --
    Aaron Bertrand
    SQL Server MVP
    [url]http://www.aspfaq.com/[/url]




    "Dave" <1@1.ca> wrote in message news:40A2592C.7050401@1.ca...
    > Yes, same server - sorry. And I agree, MSDE would be better, but I do
    > not have that option at the moment.
    >
    > Right now, I have both setup to use the full path
    > D:\webs\site_a\data\db.mdb in their connection strings...
    >
    > Any reason why I should NOT do that?
    >
    > Why do many example of DSN Less connection strings use Server.MapPath?
    >
    > Any performance gains by doing that? Security considerations?
    >
    >
    >
    > TomB wrote:
    >
    > > I assume this is the same server since you didn't say otherwise.
    > > site_a should continue as is.
    > > site_a_news should use D:\webs\site_a\data\db.mdb in its connection
    string.
    > >
    > > A different (likely better) solution would be to move the database to
    > > d:\database\db.mdb and both site_a and site_a_news can get to it from
    there.
    > >
    > > MSDE would likely be even better.
    > >
    > > TomB
    > >
    > >
    > > "Dave" <1@1.ca> wrote in message
    > > news:uCjtu%23DOEHA.2780@TK2MSFTNGP09.phx.gbl...
    > >
    > >>I have two sites:
    > >>
    > >>[url]www.site_A.com[/url] & [url]www.site_A_news.com[/url]
    > >>
    > >>Site_A is in d:\webs\site_a & uses an Access DB in
    > >>d:\webs\site_a\data\db.mdb
    > >>
    > >>Site_A_news is in d:\webs\site_a\site_a_news also requires access to
    > >>that Access Database.
    > >>
    > >>How should I setup the connection string so both webs can share the same
    > >>database?
    > >
    > >
    > >

    Aaron Bertrand - MVP Guest

  9. #8

    Default Re: Server.MapPath connection string question.

    Thanks Tom.

    One final question.. how could the web user download the db? How would
    (could) they find out the path?

    TomB wrote:
    > The downside to having your database within your site, is that a user could
    > type in the url to the database and download it.
    > [url]http://site_a/data/db.mdb[/url]
    > To fix, you can rename the database db.asp
    >
    > I think the main reasons for using Server.MapPath are
    > a) if it's sample code they don't know where you are going to put it
    > b) if you move the site to a new server, or a new directory, the link is
    > relative so it won't break.
    >
    > Tom B
    >
    > "Dave" <1@1.ca> wrote in message
    > news:ujWcKNEOEHA.3264@tk2msftngp13.phx.gbl...
    >
    >>Yes, same server - sorry. And I agree, MSDE would be better, but I do
    >>not have that option at the moment.
    >>
    >>Right now, I have both setup to use the full path
    >>D:\webs\site_a\data\db.mdb in their connection strings...
    >>
    >>Any reason why I should NOT do that?
    >>
    >>Why do many example of DSN Less connection strings use Server.MapPath?
    >>
    >>Any performance gains by doing that? Security considerations?
    >>
    >>
    >>
    >>TomB wrote:
    >>
    >>
    >>>I assume this is the same server since you didn't say otherwise.
    >>>site_a should continue as is.
    >>>site_a_news should use D:\webs\site_a\data\db.mdb in its connection
    >
    > string.
    >
    >>>A different (likely better) solution would be to move the database to
    >>>d:\database\db.mdb and both site_a and site_a_news can get to it from
    >
    > there.
    >
    >>>MSDE would likely be even better.
    >>>
    >>>TomB
    >>>
    >>>
    >>>"Dave" <1@1.ca> wrote in message
    >>>news:uCjtu%23DOEHA.2780@TK2MSFTNGP09.phx.gbl. ..
    >>>
    >>>
    >>>>I have two sites:
    >>>>
    >>>>[url]www.site_A.com[/url] & [url]www.site_A_news.com[/url]
    >>>>
    >>>>Site_A is in d:\webs\site_a & uses an Access DB in
    >>>>d:\webs\site_a\data\db.mdb
    >>>>
    >>>>Site_A_news is in d:\webs\site_a\site_a_news also requires access to
    >>>>that Access Database.
    >>>>
    >>>>How should I setup the connection string so both webs can share the same
    >>>>database?
    >>>
    >>>
    >>>
    >
    >
    Dave Guest

  10. #9

    Default Re: Server.MapPath connection string question.

    Usually just by sheer luck.
    However, other things can happen.

    a) Perhaps a user hits an error and the error message says something that
    gives it away.
    b) Your asp page doesn't get processed for some reason, and the source code
    is displayed instead.
    c) You accidentally allow directory browsing and don't have a default page.
    d) Good guesswork.
    e) Once a person posted a question on a newsgroup with their real email
    address (the usual NOSPAM was in there) and because of the information they
    provided, their database could easily have been downloaded. Note I've seen
    this with SQL too, people posting straight from their source with IP of
    their server, username and password. Invariably it's sa.

    All in all it's pretty unlikely to happen. But it could.
    TomB


    "Dave" <1@1.ca> wrote in message
    news:eyl0aGGOEHA.3016@tk2msftngp13.phx.gbl...
    > Thanks Tom.
    >
    > One final question.. how could the web user download the db? How would
    > (could) they find out the path?
    >
    > TomB wrote:
    > > The downside to having your database within your site, is that a user
    could
    > > type in the url to the database and download it.
    > > [url]http://site_a/data/db.mdb[/url]
    > > To fix, you can rename the database db.asp
    > >
    > > I think the main reasons for using Server.MapPath are
    > > a) if it's sample code they don't know where you are going to put it
    > > b) if you move the site to a new server, or a new directory, the link is
    > > relative so it won't break.
    > >
    > > Tom B
    > >
    > > "Dave" <1@1.ca> wrote in message
    > > news:ujWcKNEOEHA.3264@tk2msftngp13.phx.gbl...
    > >
    > >>Yes, same server - sorry. And I agree, MSDE would be better, but I do
    > >>not have that option at the moment.
    > >>
    > >>Right now, I have both setup to use the full path
    > >>D:\webs\site_a\data\db.mdb in their connection strings...
    > >>
    > >>Any reason why I should NOT do that?
    > >>
    > >>Why do many example of DSN Less connection strings use Server.MapPath?
    > >>
    > >>Any performance gains by doing that? Security considerations?
    > >>
    > >>
    > >>
    > >>TomB wrote:
    > >>
    > >>
    > >>>I assume this is the same server since you didn't say otherwise.
    > >>>site_a should continue as is.
    > >>>site_a_news should use D:\webs\site_a\data\db.mdb in its connection
    > >
    > > string.
    > >
    > >>>A different (likely better) solution would be to move the database to
    > >>>d:\database\db.mdb and both site_a and site_a_news can get to it from
    > >
    > > there.
    > >
    > >>>MSDE would likely be even better.
    > >>>
    > >>>TomB
    > >>>
    > >>>
    > >>>"Dave" <1@1.ca> wrote in message
    > >>>news:uCjtu%23DOEHA.2780@TK2MSFTNGP09.phx.gbl. ..
    > >>>
    > >>>
    > >>>>I have two sites:
    > >>>>
    > >>>>[url]www.site_A.com[/url] & [url]www.site_A_news.com[/url]
    > >>>>
    > >>>>Site_A is in d:\webs\site_a & uses an Access DB in
    > >>>>d:\webs\site_a\data\db.mdb
    > >>>>
    > >>>>Site_A_news is in d:\webs\site_a\site_a_news also requires access to
    > >>>>that Access Database.
    > >>>>
    > >>>>How should I setup the connection string so both webs can share the
    same
    > >>>>database?
    > >>>
    > >>>
    > >>>
    > >
    > >

    TomB Guest

  11. #10

    Default Re: Server.MapPath connection string question.

    Good points, thanks Tom. I'll adjust accordingly :)

    TomB wrote:
    > Usually just by sheer luck.
    > However, other things can happen.
    >
    > a) Perhaps a user hits an error and the error message says something that
    > gives it away.
    > b) Your asp page doesn't get processed for some reason, and the source code
    > is displayed instead.
    > c) You accidentally allow directory browsing and don't have a default page.
    > d) Good guesswork.
    > e) Once a person posted a question on a newsgroup with their real email
    > address (the usual NOSPAM was in there) and because of the information they
    > provided, their database could easily have been downloaded. Note I've seen
    > this with SQL too, people posting straight from their source with IP of
    > their server, username and password. Invariably it's sa.
    >
    > All in all it's pretty unlikely to happen. But it could.
    > TomB
    >
    >
    > "Dave" <1@1.ca> wrote in message
    > news:eyl0aGGOEHA.3016@tk2msftngp13.phx.gbl...
    >
    >>Thanks Tom.
    >>
    >>One final question.. how could the web user download the db? How would
    >>(could) they find out the path?
    >>
    >>TomB wrote:
    >>
    >>>The downside to having your database within your site, is that a user
    >
    > could
    >
    >>>type in the url to the database and download it.
    >>>[url]http://site_a/data/db.mdb[/url]
    >>>To fix, you can rename the database db.asp
    >>>
    >>>I think the main reasons for using Server.MapPath are
    >>>a) if it's sample code they don't know where you are going to put it
    >>>b) if you move the site to a new server, or a new directory, the link is
    >>>relative so it won't break.
    >>>
    >>>Tom B
    >>>
    >>>"Dave" <1@1.ca> wrote in message
    >>>news:ujWcKNEOEHA.3264@tk2msftngp13.phx.gbl...
    >>>
    >>>
    >>>>Yes, same server - sorry. And I agree, MSDE would be better, but I do
    >>>>not have that option at the moment.
    >>>>
    >>>>Right now, I have both setup to use the full path
    >>>>D:\webs\site_a\data\db.mdb in their connection strings...
    >>>>
    >>>>Any reason why I should NOT do that?
    >>>>
    >>>>Why do many example of DSN Less connection strings use Server.MapPath?
    >>>>
    >>>>Any performance gains by doing that? Security considerations?
    >>>>
    >>>>
    >>>>
    >>>>TomB wrote:
    >>>>
    >>>>
    >>>>
    >>>>>I assume this is the same server since you didn't say otherwise.
    >>>>>site_a should continue as is.
    >>>>>site_a_news should use D:\webs\site_a\data\db.mdb in its connection
    >>>
    >>>string.
    >>>
    >>>
    >>>>>A different (likely better) solution would be to move the database to
    >>>>>d:\database\db.mdb and both site_a and site_a_news can get to it from
    >>>
    >>>there.
    >>>
    >>>
    >>>>>MSDE would likely be even better.
    >>>>>
    >>>>>TomB
    >>>>>
    >>>>>
    >>>>>"Dave" <1@1.ca> wrote in message
    >>>>>news:uCjtu%23DOEHA.2780@TK2MSFTNGP09.phx.gbl. ..
    >>>>>
    >>>>>
    >>>>>
    >>>>>>I have two sites:
    >>>>>>
    >>>>>>[url]www.site_A.com[/url] & [url]www.site_A_news.com[/url]
    >>>>>>
    >>>>>>Site_A is in d:\webs\site_a & uses an Access DB in
    >>>>>>d:\webs\site_a\data\db.mdb
    >>>>>>
    >>>>>>Site_A_news is in d:\webs\site_a\site_a_news also requires access to
    >>>>>>that Access Database.
    >>>>>>
    >>>>>>How should I setup the connection string so both webs can share the
    >
    > same
    >
    >>>>>>database?
    >>>>>
    >>>>>
    >>>>>
    >>>
    >
    >
    Dave Guest

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139