How do I setup a ODBC connection correctly?

Discussion in 'Databases' started by varcomp, Jan 20, 2006.

Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.
  1. can anyone tell me how they did it or something?

    I heard I have to edit something to point in the right place

    I have loaded the database into the database folder but the site is still reading of the old location

    thanks very much
    Steve
    /emoticons/smile.gif
     
  2. I saw this article but I'm not sure what to do with it:


    http://kb.discountasp.net/article.aspx?id=10191



    Query an Access database with ASP using a DSN-less connection.

    The information in this article applies to:
    # ASP
    # MS Access

    DETAILS

    <%

    Dim cnnSimple ' ADO connection
    Dim rstSimple ' ADO recordset
    Set cnnSimple = Server.CreateObject('ADODB.Connection')

    ' DSNLess
    cnnSimple.Open ('Provider=Microsoft.Jet.OLEDB.4.0;Data Source=' & Server.MapPath('\test.mdb'))

    Set rstSimple = cnnSimple.Execute('SELECT * FROM tbltest')

    %>
    <P> Connecting to Access with Ole connection </P>

    <table border='1'>
    <%
    Do While Not rstSimple.EOF
    %>
    <tr>
    <td><%= rstSimple.Fields(0).Value %></td>
    <td><%= rstSimple.Fields(1).Value %></td>
    </tr>
    <%
    rstSimple.MoveNext
    Loop
    %>
    </table>
    <%

    rstSimple.Close
    Set rstSimple = Nothing
    cnnSimple.Close
    Set cnnSimple = Nothing
    %>
     
  3. Bruce

    Bruce DiscountASP.NET Staff

  4. I don't understand what to do with it do I save it as a webpage by itself in the root or something?

    It is probably pretty easy, I just don't know what to do with it or where to put it

    what do I do? do I open frontpage of dreamweaver, copy the code and enter in where my database is located where is says ('\test.mdb'))

    thank you so much for the reply, I really want to make my database hidden so people won't be able to download it (like they can now)

    thank you thank you
    Steve
     
  5. Bruce

    Bruce DiscountASP.NET Staff

    if you do not want people to download your DB, you can upload it to the _database directory. This directory has special permission that prohibits download.

    Bruce

    DiscountASP.NET
    www.DiscountASP.NET
     
  6. I realize that but I can't figure out how to point to that data, I don't know if I have to ADD the page info below in a webpage or something or Change something in my webcart, thanks very much, I recommend you guys almost daily

    Query an Access database with ASP using a DSN-less connection.

    The information in this article applies to:
    # ASP
    # MS Access

    DETAILS

    <%

    Dim cnnSimple ' ADO connection
    Dim rstSimple ' ADO recordset
    Set cnnSimple = Server.CreateObject('ADODB.Connection')

    ' DSNLess
    cnnSimple.Open ('Provider=Microsoft.Jet.OLEDB.4.0;Data Source=' & Server.MapPath('\test.mdb'))

    Set rstSimple = cnnSimple.Execute('SELECT * FROM tbltest')

    %>
    <P> Connecting to Access with Ole connection </P>

    <table border='1'>
    <%
    Do While Not rstSimple.EOF
    %>
    <tr>
    <td><%= rstSimple.Fields(0).Value %></td>
    <td><%= rstSimple.Fields(1).Value %></td>
    </tr>
    <%
    rstSimple.MoveNext
    Loop
    %>
    </table>
    <%

    rstSimple.Close
    Set rstSimple = Nothing
    cnnSimple.Close
    Set cnnSimple = Nothing
    %>
     
  7. Bruce

    Bruce DiscountASP.NET Staff

    Change this line

    cnnSimple.Open ('Provider=Microsoft.Jet.OLEDB.4.0;Data Source=' & Server.MapPath('\test.mdb'))

    to

    cnnSimple.Open ('Provider=Microsoft.Jet.OLEDB.4.0;Data Source=' & Server.MapPath('\_database\[yourdatabaseName].mdb'))

    Bruce

    DiscountASP.NET
    www.DiscountASP.NET
     
  8. I figured that but what kind of file do I save it as a html page, a text file etc? and do I save it to the root? as in varunlimited.com/whateverthenameis

    I really appreciate your help

    thanks
    Steve
     
  9. I'm not sure what you mean about "what kind of file". You should save your access database file as an mdf file. If you put the file in a non-password protected section on your website, people can download the file if they know where it exists (security risk). So put it in the _database folder we create for you. No one has access to this.


    Joel Thoms

    DiscountASP.NET
    http://www.DiscountASP.NET
     
  10. I meant what kind of file for the coding that I posted here that I got from http://kb.discountasp.net/article.aspx?id=10191

    I tried putting the file into the database folder but that didn't work, maybe because the application needed to be restarted (I deleted the database folder by accident recently from where it is currently saved at and working from, then I replaced it and it didn't work until the server tech guys at discountasp.net reset the application, I'm not sure what they did but after they reset it or whatever it worked)

    I'm wondering if my database just didn't work because I didn't have the application restarted afterwards, because it sounds like what you are telling me is all I have to do is move the database file. (if that is the case maybe I'm confused about what the coding in the article will do for me)

    I really appreciate the help, if you need any computer hardware I'll give you the hookup.

    thanks
    Steve
     
  11. I'm still unclear about the kind of file. You are using an access database (mdf) right? If you are using anything else, that article will not work for you.

    You shouldn't need to perform any kind of reset on your application.

    If you are still unable to get this to work, then please give us a URL to an example of it not working, along with where you put your mdf file, the name of your mdf fileand the source code that you are using to access this file.


    Joel Thoms

    DiscountASP.NET
    http://www.DiscountASP.NET
     
  12. Steve,

    I feel your pain. I am also trying to connect to an Access database. I can connect, but I can't view the tables.

    Have you used the "Access ODBC Tool" provided by DiscountASP?

    You can create a DSN there. Then use that to connect with.

    Regards,
    Daniel
     
  13. I got it working.

    The shopping cart I use was written by some people that don't speak english very well so it is hard to get the right answer from them.

    I just needed to edit the settings file to look for the correct dsn name

    you can connect but can't read the tables? Hopefully your mdb (access database) file isn't corrupt, try opening it in access locally on your personal computer, after you verify that it is ok, resave it in your _database folder and also make sure the dsn name is correct it will have your company name in it then a _ and then whatever you name it

    if you need more help I'll do my best, I'm not a pro but I'll do what I can to help

    thanks
    Steve
     
Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.

Share This Page