Web Analytics Made Easy -
StatCounter conn string problems - CodingForum


No announcement yet.

conn string problems

  • Filter
  • Time
  • Show
Clear All
new posts

  • conn string problems

    Hello everyone,

    I built a login structure using a databe for a website and I cannot get the connection string right. You can view the website at: NS Fire CISM login
    The login was working and then I moved the website to a different server and all of a sudden the login wouldn't work anymore. The Conn string I used was:

    <% connCISM = "DRIVER={Microsoft Access Driver (*.mdb)} ; DBQ= & Server.MapPath(wwwroot\Database\CISM.mdb)"%>

    and when you enter your login info this is the error:

    HTTP 500 - Internal server error

    I just have no idea why this isn't working. I really need to get this fixed. I've been searching for an answer for a while.

    Thanks in advance everyone!

  • #2
    Does that connection string really work in the previous server?
    That has syntax errors. The quotes are in the wrong place and missing.

    <% connCISM = "DRIVER={Microsoft Access Driver (*.mdb)} ; DBQ=" & Server.MapPath("wwwroot\Database\CISM.mdb") & ";"%>

    Regarding your question, what directory is the database located now? Obviously, you need to change the path of the database to point to a new location.
    vBulletin Mods That Rock!


    • #3
      this can help connStrings


      • #4

        I changed the mistakes but it still won't work so I'll take a look at the recommended website and see what it tells me. Who wouldn've thought there was a website www.connectionstrings.com?

        1 question: Does the path have to be direct path straight from the main directory? The database is in a database folder inside the "wwwroot" folder where all the pages are. Also, inside the main directory there is a "db" folder....would it be better for me to put it there? Would the server want me to?

        Thanks for your responses!


        • #5
          you don't even need to list the wwwroot when you write out the server.mappath Server.MapPath("\Database\CISM.mdb")

          here is another one you can try. On Some servers this works better.

          connCISM = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Server.MapPath("\Database\CISM.mdb") & ; Jet OLEDB:database Password=YourPasswordGoesHere;"
          Last edited by miranda; Feb 11, 2004, 02:22 PM.


          • #6
            It is always recommended to put your database out of reach from http request. If you put your db inside the "wwwroot/database" directory, the db would be accessible by anyone:

            The db should be put above the root directory.

            The code now should be:
            connCISM = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Server.MapPath("..\database\CISM.mdb") & ";"
            Last edited by glenngv; Apr 27, 2004, 06:06 AM.
            vBulletin Mods That Rock!


            • #7
              Another way to do the same thing glenngv is recommending (and he's right - you need to make sure your database is not downloadable, if someone guesses the name!):
              sConnString = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & _
              Mid(Server.MapPath("\"), 1, InStrRev(Server.MapPath("\"),"\")-1) & "\PUTYOURFILENAMEHERE.mdb;" & _
              "Persist Security Info=False;"
              Set Conn = Server.CreateObject("ADODB.Connection")
              Conn.Open sConnString
              'Put whatever here!
              Set Conn = Nothing
              I haven't used Microsoft Access in quite a while, but this syntax always worked for me... on Brinkster as well.
              Former ASP Forum Moderator - I'm back!

              If you can teach yourself how to learn, you can learn anything. ;)


              • #8
                I would like to correct the code I posted.
                The path should be:


                without the backlash at the beginning.

                Sample output is:


                whammy, that' also correct. But if molenaar_m wants his/her directory structure to be a little organized, he/she needs to specify a subfolder.

                Mid(Server.MapPath("\"), 1, InStrRev(Server.MapPath("\"),"\")-1) & "\database\PUTYOURFILENAMEHERE.mdb;"

                The output would be the same as in my code's.
                vBulletin Mods That Rock!


                • #9

                  Perfect....this is exactly the help I was looking for. Thanks for the replies everyone. I will try a couple of your solutions after and hopefully they will fix the problem.