locked
Search and Results with Access Database RRS feed

  • Question

  • User-1190456421 posted

    Hello forum members:

    I followed the instructions on  http://msdn.microsoft.com/en-us/expression/dd571513.aspx and it is now working on my local PC and I can see the search and results on Preview in Browser.

    However, when I uploaded both search and results files (.aspx) to a remote server, I can see the search.aspx and I put a word, but nothing happens and the windows stays on the same page search.aspx. And there is NO error message.

    ~~This is the Access Data Source and the Access Database location.~~

    <asp:AccessDataSource id="dsn1006984_AccessDataSource1" runat="server" DataFile="D:\CustomerData\webspaces\webspace_00102934\private\database\English-Japanese-Dictionary-2008-02-TAC.mdb" SelectCommand="SELECT [English], [Japanese], [Class] FROM [TechnicalWords] WHERE ([English] LIKE '%' + ? + '%')">  < SelectParameters>  < asp:FormParameter FormField="TextBox1" Name="English" Type="String" />  < /SelectParameters>  < /asp:AccessDataSource>  < asp:GridView id="GridView1" runat="server" AutoGenerateColumns="False" DataSourceID="dsn1006984_AccessDataSource1" HorizontalAlign="Center">

    I am wondering if you can see anything wrong or if you can suggest to make some adjustments on this.

    Thank you.

    Monday, March 9, 2015 2:22 AM

All replies

  • User1577371250 posted

    Hi,

    You need to follow the steps here.

    1. Always you need to keep your .mdb file in App_Data folder in your application. It will prevent the user to directly accessing the DB or downloading it.

    2. you can give the path as below.

    <asp:AccessDataSource id="dsn1006984_AccessDataSource1" runat="server" 
    DataFile="~/App_Data/English-Japanese-Dictionary-2008-02-TAC.mdb"
    SelectCommand="SELECT [English], [Japanese], [Class] FROM [TechnicalWords] WHERE ([English] LIKE '%' + ? + '%')">

    Monday, March 9, 2015 3:04 AM
  • User-2110585397 posted

    Hi Cyber,

    For your post, you used the absolute physical path. It worked fine on local machine because the db file exists. But I think it not exist on remote server. So I think you need to use relative path. Please try the following code:

    <asp:AccessDataSource ID="AccessDataSource1" runat="server" DataFile="<%$ appSettings:db %>"

    Web.Config.

    <appSettings>
    <add key="db" value="~\App_Data\StreamLineDev.mdb" />
    <appSettings>

    Hope this can be helpful to you.

    Sherwin Zhao
    Best Regards

    Monday, March 9, 2015 11:04 PM
  • User-1190456421 posted

    Hello Lokesh and Sherwin

    Thank you very much for your suggestions.

    I tried both methods, but I still cannot make a connection to Access DB.

    A remote server is a shared hosting and they say that the exact location of the Access DB by default is D:\CustomerData\webspaces\webspace_00102934\private\database

    However, they say I can create other directory, so I even created App_Data directory at: 1) wwwroot\App_Data and 2) wwwroot\Dictionary\App_Data and placed the Access DB as well.

    <asp:AccessDataSource id="dsn1006984_AccessDataSource1" runat="server" DataFile="~/App_Data/English-Japanese-Dictionary-2008-02-TAC.mdb"

    <asp:AccessDataSource id="dsn1006984_AccessDataSource1" runat="server" DataFile="<%$ appSettings:db %>"

    Plus web.config as:

    <appSettings>
    <add key="db" value="~\App_Data\English-Japanese-Dictionary-2008-02-TAC.mdb" />
    <\appSettings>

    And still it doesn't work. I am going to send an e-mail to a hosting company to look into and post back as soon as I hear from them.

    Thank you.

    Tuesday, March 10, 2015 7:53 PM
  • User-2110585397 posted

    Hi Cyber,

    I have following suggestions:

    1. If you get any error information from page, include JS error message, if yes please share it.

    2. You should add App_Data folder in your solution in VS. And this folder must be under whole application root path.

    Sherwin Zhao
    Best Regards

    Wednesday, March 11, 2015 1:48 AM
  • User1577371250 posted

    Hi,

    You should add the App_Data folder in your Visual Studio Solution as shown in below image and place the database file in side that folder.

    You can use like this later.

    <asp:AccessDataSource id="dsn1006984_AccessDataSource1" runat="server" 
    DataFile="~/App_Data/English-Japanese-Dictionary-2008-02-TAC.mdb" 
    SelectCommand="SELECT [English], [Japanese], [Class] FROM [TechnicalWords] WHERE ([English] LIKE '%' + ? + '%')">



    Wednesday, March 11, 2015 2:51 AM
  • User-1190456421 posted

    Hello Sherwin

    Thank you again for looking into this.

    According to a hosting company, a DSN needs to be used for the Access DB connection, and the control panel of the hosting company automatically adds dsn1006984 to AccessDataSource1, then it become dsn1006984_AccessDataSource1

    Does this sound right?

    Once again, thank you.

    Wednesday, March 11, 2015 3:06 AM
  • User-1199946673 posted

    According to a hosting company, a DSN needs to be used for the Access DB connection, and the control panel of the hosting company automatically adds dsn1006984 to AccessDataSource1, then it become dsn1006984_AccessDataSource1

    Does this sound right?

    No, I don't see why a DSN needs to be used, unless the hosting company has blocked OleDb. When they did, you can't use an AccessDataSource, because it uses OleDb. Instead, use an SqlDataSource instead, But first, I woudl suggest you try to connect to you database in code behind, to see if it is possible to connect to the database using OleDb, and if nit, which error you get so we can help you to solve it

    http://www.mikesdotnetting.com/article/26/parameter-queries-in-asp-net-with-ms-access

    Here you can find some sample code to connect to an access database. Please try?

    Friday, March 13, 2015 6:23 AM
  • User-1190456421 posted

    Hello:

    I apologize for not posting back sooner.

    I've been communicating back and forth with a hosting company and they provided an error message as follows:

    [InvalidOperationException: The WebResource.axd handler must be registered in the configuration to process this request.
    
    <!-- Web.Config Configuration File -->
    
    <configuration>
    
        <system.web>
    
            <httpHandlers>
    
                <add path="WebResource.axd" verb="GET" type="System.Web.Handlers.AssemblyResourceLoader" validate="True" />
    
            </httpHandlers>
    
        </system.web>
    
    </configuration>]
    
       System.Web.Handlers.AssemblyResourceLoader.GetWebResourceUrlInternal(Assembly assembly, String resourceName, Boolean htmlEncoded) +10949217
    
       System.Web.Handlers.AssemblyResourceLoader.GetWebResourceUrl(Type type, String resourceName, Boolean htmlEncoded) +364
    
       System.Web.UI.ClientScriptManager.RenderWebFormsScript(HtmlTextWriter writer) +77
    
       System.Web.UI.Page.BeginFormRender(HtmlTextWriter writer, String formUniqueID) +1826
    
       System.Web.UI.HtmlControls.HtmlForm.RenderChildren(HtmlTextWriter writer) +75
    
       System.Web.UI.HtmlControls.HtmlForm.Render(HtmlTextWriter output) +87
    
       System.Web.UI.HtmlControls.HtmlForm.RenderControl(HtmlTextWriter writer) +53
    
       System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +240
    
       System.Web.UI.Page.Render(HtmlTextWriter writer) +38
    
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +4240
    

    Can you see what is wrong?

    Once again, thank you for looking into this.

    Friday, March 20, 2015 8:14 PM
  • User-1199946673 posted

    [InvalidOperationException: The WebResource.axd handler must be registered in the configuration to process this request.

    Let me help you

    http://bit.ly/1FwAOYx

    But this has nothing to do with the Original question

    Monday, March 23, 2015 7:08 PM