0

I am making a web application and have a webform connected to an access database table. For one of my queries I have a table with supplier info and I need to filter the results by name, city, and type.

I used the query builder to have the parameters input by the user through 3 textboxes (one for each parameter). When I run the query in the query builder the results come up fine, but when I run it through a browser it fails (the form shows up fine, but it's not taking the input parameters in the textbox to populate the table). I made sure I linked the parameters to the texbox control through the wizard.

I've built forms with a single input parameter controlled with a single textbox and those have worked just fine, but when I used multiple parameters and textboxes it doesn't work in the browser.

I appreciate any help! Thanks!

1
  • Are you using asp:AccessDataSource?
    – jignesh
    Apr 18, 2014 at 6:20

1 Answer 1

0

Make sure you bind control with parameter.

   <SelectParameters>
       <asp:ControlParameter  Name="Comments" PropertyName="Text" Type="String" />
       <asp:ControlParameter ControlID="txtLastName" Name="Title" PropertyName="Text" Type="String" />
    </SelectParameters>

You can pass parameters runtime as below.

 <SelectParameters>
    <asp:Parameter Name="Comments" Type="String" />
        <asp:Parameter Name="Title" Type="String" />
    </SelectParameters>

 protected void AccessDataSource1_Selecting(object sender, System.Web.UI.WebControls.SqlDataSourceSelectingEventArgs e)
    {
        if (txtFirstName.Text.Length > 0 && txtLastName.Text.Length > 0)
        {
            e.Command.Parameters["parameter1"].Value = txtFirstName.Text;
            e.Command.Parameters["parameter2"].Value = txtLastName.Text;
        }
    }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.