locked
Input parameter in AccessDataSource RRS feed

  • Question

  • User-33978631 posted

    Hi,

    I just joined this forum since I'm stucked with the following code in my Access DB, which I have been trying to load list of active project in my MDB database. The purpose of selecting the list is to filter / limit the user so they didn't input data to in-active project. So far this is what I got, but it always came up with all the project eventhough I have marked them as in-active. The structure of the table is simple, only Project ID (Identity), Project Code (String), Project Name (String), Project Status (Yes/No)

    Appreciate any help from all you guys. Regards, Sea

    PS: I didn't use vb code behind or other setting since this is not my original program, I just want to modify this to sync with my other DB 

    
    
    <asp:AccessDataSource ID="dbsReadProjects" runat="server" DataFile="~/timesheet.mdb" 
    SelectCommand="SELECT ProjectCode, ProjectName, ProjectStatus FROM Projects WHERE ProjectStatus = True ORDER BY ProjectName">
    </asp:AccessDataSource>
    
    <asp:DropDownList ID="NewProject" runat="server" DataSourceID="dbsReadProjects" 
    DataTextField="ProjectName" DataValueField="ProjectCode">
    </asp:DropDownList>
    Tuesday, February 14, 2012 4:15 AM

Answers

  • User1950091109 posted

    <asp:AccessDataSource ID="dsId" runat="server"><SelectParameters >
    <asp:Parameter Type="Boolean" DefaultValue="True"/>
    </SelectParameters></asp:AccessDataSource>

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, February 14, 2012 4:58 AM
  • User-33978631 posted

    Pardon me but there is something weird just happenned to the code and the database.
    Just now I decided to get fresh copy of the database and redo the code again, and it works just fine.
    Don't know exactly what happened, but I'm now moved on to the next step of the project.
    Thank you for all the help, especially for Muhammad. It's definitely boost my interest to learn more.

    Once again thanks, and I will mark this thread as ANSWER.

    Regards, Sea 

     

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, February 15, 2012 1:00 AM

All replies

  • User1950091109 posted

    Try

    WHERE ProjectStatus = Yes

    instead Laughing

    Tuesday, February 14, 2012 4:19 AM
  • User-33978631 posted

    No luck here. still in-active project were listed in the dropdownlist 

    I have tried to put ProjectStatus = 1, ProjectStatus = 'True' as well. 

    Or is there any way such as put "Select ProjectCode, ProjectName, ProjectStatus FROM Projects WHERE (ProjectStatus = ?) ORDER by ProjectName"

    And i put "<SelectParameters>" syntax? Is it possible? 

    Tuesday, February 14, 2012 4:29 AM
  • User1950091109 posted

    That ofcourse will be better

    try this

    <asp:AccessDataSource ID="ID" ......>
        <SelectParameters>
            <asp:Parameter DefaultValue="hardCodedValue" 
                           Name="parameterName" 
                           Type="dataType" />
        </SelectParameters>
    </asp:AccessDataSource>
    Tuesday, February 14, 2012 4:55 AM
  • User1950091109 posted

    <asp:AccessDataSource ID="dsId" runat="server"><SelectParameters >
    <asp:Parameter Type="Boolean" DefaultValue="True"/>
    </SelectParameters></asp:AccessDataSource>

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, February 14, 2012 4:58 AM
  • User-33978631 posted

    Have done the following for the code, but it's funny coz the data is not displayed properly.
    Is there anything else I should check that might interfere with the dropdownlist?

    <asp:AccessDataSource ID="dbsReadProjects" runat="server" DataFile="~/timesheet.mdb"
    SelectCommand="SELECT [ProjectCode], [ProjectName], [ProjectStatus] FROM [Projects] WHERE ([ProjectStatus] = ?) ORDER BY ProjectName">
    <SelectParameters>
    <asp:Parameter Type="Boolean" DefaultValue="True" />
    </SelectParameters>
    </asp:AccessDataSource>

    <asp:DropDownList ID="NewProject" runat="server" DataSourceID="dbsReadProjects" DataTextField="ProjectName" DataValueField="ProjectCode"></asp:DropDownList>

    Tuesday, February 14, 2012 8:34 PM
  • User-33978631 posted

    Pardon me but there is something weird just happenned to the code and the database.
    Just now I decided to get fresh copy of the database and redo the code again, and it works just fine.
    Don't know exactly what happened, but I'm now moved on to the next step of the project.
    Thank you for all the help, especially for Muhammad. It's definitely boost my interest to learn more.

    Once again thanks, and I will mark this thread as ANSWER.

    Regards, Sea 

     

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, February 15, 2012 1:00 AM