locked
Need ASP / Access MDB help (simple task) RRS feed

  • Question

  • User153330903 posted

    I have a website on GoDaddy, I also have an Access.mdb sitting on their server. I just want a simple ASP page that the user can enter a number into a textbox and hit "Go", the Go button would trigger a query, and return all of the records having to do with that number. I don't need to insert or change the returning data, just show it in a table I guess.

    Could someone give me hand here, Thanks.    

    Thursday, February 5, 2009 12:36 PM

Answers

  • User-821857111 posted

    they tell me that there is an issue with utilizing Front Page Extensions, and gaining access to an Access database
     

    Really??!?  It's a pity you don't actually show the runtime error message you get.  My guess would be something to do with leading ../ and top level directories.  You should use a SqlDataSource control for connecting to Access and then apply the connection string like this:

    Provider=Microsoft.Jet.OleDb.4.0;Data Source=|DataDirectory|Trakit.mdb


    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, February 5, 2009 5:27 PM
  • User-1199946673 posted

    My guess would be something to do with leading ../ and top level directories. 

    A, I just noticed that the Datafile property valus is ../App_data/TrakIt.mdb instead of ~/App_data/TrakIt.mdb in my example. Where exactly do you have the database? ~/App_data/ or |DataDirectory| in Mikes example both pointing to the App_Data folder in the Root of the website...

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, February 5, 2009 5:57 PM

All replies

  • User-1199946673 posted

    This is very simple:

    <asp:TextBox ID="TextBox1" runat="server" AutoPostBack="true" />
    <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="true" DataSourceID="AccessDataSource1" />
    <asp:AccessDataSource ID="AccessDataSource1" runat="server"
      DataFile="~/App_Data/your_database.mdb"
      SelectCommand="SELECT * FROM [tour_table] WHERE ([numberfield] = ?)">
      <SelectParameters>
        <asp:ControlParameter ControlID="TextBox1" Name="numberfield" PropertyName="Text" />
      </SelectParameters>
    </asp:AccessDataSource>

    Make sure that you put your database in the App_Data folder!

    Thursday, February 5, 2009 1:15 PM
  • User153330903 posted

    I tried to do that before I wrote the post thinking that it would be an easy task. I have an intranet with plenty of gridviews and detailview. However for some reason it just doesn't work when I post this code up on the web. I get a runtime error. Is there anyway to see if I have the correct location for the DB? What else could it be?

    <asp:TextBox ID="TextBox1" runat="server" AutoPostBack="true" />
    <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="true" DataSourceID="AccessDataSource1" />

    <asp:AccessDataSource runat="server" id="AccessDataSource1" DataFile="../App_data/TrakIt.mdb" SelectCommand="SELECT * FROM [Data] WHERE ([REF#] = ?)">
    <SelectParameters>
        <asp:ControlParameter ControlID="TextBox1" Name="REF#" PropertyName="Text" />
      </SelectParameters>
    </asp:AccessDataSource>

    This is the code I used, and received a run-time error when trying to preview the page in a browser.

     

    Thursday, February 5, 2009 2:24 PM
  • User-1199946673 posted

    What error do you get?

    If I look to your code I don't see anything strange, so I think it could be a permissions problem:

    http://www.mikesdotnetting.com/Article.aspx?ArticleID=74

     

    Thursday, February 5, 2009 3:14 PM
  • User153330903 posted

    I just got off the phone with Go Daddy, and they tell me that there is an issue with utilizing Front Page Extensions, and gaining access to an Access database. I'm using Expressions Web to develop on so I need to have the extension installed. I'm going to try and upsize my database to be a sql one, and try that. Thanks for your help. I'll keep posted.

    Thursday, February 5, 2009 3:35 PM
  • User-821857111 posted

    they tell me that there is an issue with utilizing Front Page Extensions, and gaining access to an Access database
     

    Really??!?  It's a pity you don't actually show the runtime error message you get.  My guess would be something to do with leading ../ and top level directories.  You should use a SqlDataSource control for connecting to Access and then apply the connection string like this:

    Provider=Microsoft.Jet.OleDb.4.0;Data Source=|DataDirectory|Trakit.mdb


    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, February 5, 2009 5:27 PM
  • User-1199946673 posted

    My guess would be something to do with leading ../ and top level directories. 

    A, I just noticed that the Datafile property valus is ../App_data/TrakIt.mdb instead of ~/App_data/TrakIt.mdb in my example. Where exactly do you have the database? ~/App_data/ or |DataDirectory| in Mikes example both pointing to the App_Data folder in the Root of the website...

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, February 5, 2009 5:57 PM