"AND" "OR" STATEMENT

I have the following select statement.   I want to give the user the option for puting in "PN" or SN or Both.   The following stement works if both are selected but not individually.

<asp:AccessDataSource runat="server" ID="AccessDataSource1" DataFile="DB1.mdb" SelectCommand="SELECT [ID], [desc1], [mpn1], [sn1], [tool1], [caldate1], [duedate2], [DueDays], [int1], [loc1], [own1], [effect1], [status1] FROM [Query1] WHERE (([mpn1] = ?) OR ([sn1] = ?))">

<SelectParameters>
<asp:controlparameter ControlID="PN" PropertyName="Text" Name="mpn1" Type="String" />
<asp:controlparameter ControlID="SN" PropertyName="Text" Name="sn1" Type="String" />
</SelectParameters>
BOEING39Asked:
Who is Participating?
 
dj_alikConnect With a Mentor Commented:
<asp:Parameter Name="@Parameter" ConvertEmptyStringToNull="true" />
0
 
dj_alikCommented:
(([mpn1] = ? OR [mpn1] IS NULL ) OR ([sn1] = ? OR ([sn1] is NULL))
0
 
BOEING39Author Commented:
Tried above code "No Joy"   Neither control works with this code.
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
dj_alikCommented:
sorry
(([mpn1] = ? OR ? IS NULL ) OR ([sn1] = ? OR ? is NULL))  
0
 
dj_alikCommented:
please try to use
(([mpn1] = @mpn1 OR @mpn1  IS NULL ) OR ([sn1] = @sn1 OR ? is @sn1 ))  
0
 
BOEING39Author Commented:
Tried both solutions neither is working:

SelectCommand="SELECT [ID], [desc1], [mpn1], [sn1], [tool1], [caldate1], [duedate2], [DueDays], [int1], [loc1], [own1], [effect1], [status1] FROM [Query1] WHERE (([mpn1] = ? OR ? IS NULL ) OR ([sn1] = ? OR ? is NULL)) ">



SelectCommand="SELECT [ID], [desc1], [mpn1], [sn1], [tool1], [caldate1], [duedate2], [DueDays], [int1], [loc1], [own1], [effect1], [status1] FROM [Query1] WHERE (([mpn1] = @mpn1 OR @mpn1  IS NULL ) OR ([sn1] = @sn1 OR ? is @sn1 )) ">
0
 
dj_alikCommented:
<asp:AccessDataSource runat="server" ID="AccessDataSource1" DataFile="DB1.mdb" SelectCommand="SELECT [ID], [desc1], [mpn1], [sn1], [tool1], [caldate1], [duedate2], [DueDays], [int1], [loc1], [own1], [effect1], [status1] FROM [Query1] WHERE (([mpn1] = @mpn1 OR @mpn1 IS NULL) OR ([sn1] = @sn1 OR @sn1 IS NULL))">

<SelectParameters>
<asp:controlparameter ControlID="PN" PropertyName="Text" Name="mpn1" Type="String" />
<asp:controlparameter ControlID="SN" PropertyName="Text" Name="sn1" Type="String" />
</SelectParameters>
0
 
BOEING39Author Commented:
Tried this as well "No Help"


<asp:AccessDataSource runat="server" ID="AccessDataSource1" DataFile="DB1.mdb"
SelectCommand="SELECT [ID], [desc1], [mpn1], [sn1], [tool1], [caldate1], [duedate2], [DueDays], [int1], [loc1], [own1], [effect1], [status1] FROM [Query1]  WHERE (([mpn1] = @mpn1 OR @mpn1 IS NULL) OR ([sn1] = @sn1 OR @sn1 IS NULL))">

            
<SelectParameters>
      <asp:controlparameter ControlID="PN" PropertyName="Text" Name="mpn1" Type="String" />
      <asp:controlparameter ControlID="SN" PropertyName="Text" Name="sn1" Type="String" />
</SelectParameters>
0
 
dj_alikCommented:
PN AND SN are texboxes?

0
 
BOEING39Author Commented:
Yes they are...
0
 
dj_alikCommented:
SET
 DefaultValue="null" for paramteres

<SelectParameters>
      <asp:controlparameter ControlID="PN" PropertyName="Text" Name="mpn1" Type="String"  DefaultValue="null" />
      <asp:controlparameter ControlID="SN" PropertyName="Text" Name="sn1" Type="String"  DefaultValue="null" />
</SelectParameters>
0
 
BOEING39Author Commented:
Parameter Control: to NULL did the trick.   Thx for the quick followup and response....................

<asp:AccessDataSource runat="server" ID="AccessDataSource1" DataFile="DB1.mdb"
SelectCommand="SELECT [ID], [desc1], [mpn1], [sn1], [tool1], [caldate1], [duedate2], [DueDays], [int1], [loc1], [own1], [effect1], [status1] FROM [Query1]  WHERE (([mpn1] = @mpn1 OR @mpn1 IS NULL) OR ([sn1] = @sn1 OR @sn1 IS NULL))">

<SelectParameters>
      <asp:controlparameter ControlID="PN" PropertyName="Text" Name="mpn1" Type="String"  DefaultValue="null" />
      <asp:controlparameter ControlID="SN" PropertyName="Text" Name="sn1" Type="String"  DefaultValue="null" />
</SelectParameters>
0
 
BOEING39Author Commented:
Very helpful and quicks responses.
0
All Courses

From novice to tech pro — start learning today.