sqlDataSource + Store Procedure + pameters IF

  • Thread starter Thread starter Don Quijote de Nicaragua
  • Start date Start date
D

Don Quijote de Nicaragua

Hello I have a sqldatasource to link it with a procedure
stored which will pass two parameters
1- @option to determine the query and @ IDNO for the code to
find, but when I finish with the wizard to configure the gridview
ALWAYS ALWAYS set the Gridview with me the first @option.
Any suggestions.
Don Quijote de Nicaragua


<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$
ConnectionStrings:csProductoTerminado %>"
SelectCommand="paAAA" SelectCommandType="StoredProcedure">
<SelectParameters>
<asp:Parameter DefaultValue="2" Name="Opcion"
Type="Int32" />
<asp:Parameter DefaultValue="6" Name="IdNo"
Type="Int32" />
</SelectParameters>
</asp:SqlDataSource>



ALTER PROCEDURE [dbo].[paAAA]
@Opcion as int,
@IdNo as int = NULL
AS
BEGIN
--List 1
IF @Opcion=1
SELECT * FROM tblOrdenes WHERE (@IdNo IS NULL OR tblOrdenesCensa.IdNo
= @IdNo)
--List 2
ELSE IF @Opcion=2
SELECT dbo.tblO.IdNo FROM dbo.tblO WHERE (@IdNo IS NULL OR
dbo.tblO.IdNo = @IdNo)
END
 
Hello I have a sqldatasource to link it with a procedure
stored which will pass  two parameters
1- @option to determine the query and  @ IDNO for the code to
find, but when I finish with the wizard to configure the gridview
 ALWAYS ALWAYS set the Gridview with me the first @option.
Any suggestions.
Don Quijote de Nicaragua

<asp:SqlDataSource ID="SqlDataSource1" runat="server"
            ConnectionString="<%$
ConnectionStrings:csProductoTerminado %>"
            SelectCommand="paAAA" SelectCommandType="StoredProcedure">
            <SelectParameters>
                <asp:Parameter DefaultValue="2" Name="Opcion"
Type="Int32" />
                <asp:Parameter DefaultValue="6" Name="IdNo"
Type="Int32" />
            </SelectParameters>
        </asp:SqlDataSource>

ALTER PROCEDURE [dbo].[paAAA]
        @Opcion as int,
        @IdNo as int = NULL
AS
BEGIN
--List 1
IF @Opcion=1
SELECT  * FROM tblOrdenes WHERE (@IdNo IS NULL OR tblOrdenesCensa.IdNo
= @IdNo)
--List 2
ELSE IF @Opcion=2
SELECT dbo.tblO.IdNo FROM dbo.tblO WHERE (@IdNo IS NULL OR
dbo.tblO.IdNo = @IdNo)
END

Actually, I don't get your problem. Do you mean that the following
line is wrong?

<asp:Parameter DefaultValue="2" Name="Opcion" Type="Int32" />
 
yes, this is my problen, in the sqldatasource is 2, but alway
retrieve the option 1, any ideas, thank you for your time.
Don Quijote de Nicaragua.


Hello I have a sqldatasource to link it with a procedure
stored which will pass  two parameters
1- @option to determine the query and  @ IDNO for the code to
find, but when I finish with the wizard to configure the gridview
 ALWAYS ALWAYS set the Gridview with me the first @option.
Any suggestions.
Don Quijote de Nicaragua
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
            ConnectionString="<%$
ConnectionStrings:csProductoTerminado %>"
            SelectCommand="paAAA" SelectCommandType="StoredProcedure">
            <SelectParameters>
                <asp:Parameter DefaultValue="2" Name="Opcion"
Type="Int32" />
                <asp:Parameter DefaultValue="6" Name="IdNo"
Type="Int32" />
            </SelectParameters>
        </asp:SqlDataSource>
ALTER PROCEDURE [dbo].[paAAA]
        @Opcion as int,
        @IdNo as int = NULL
AS
BEGIN
--List 1
IF @Opcion=1
SELECT  * FROM tblOrdenes WHERE (@IdNo IS NULL OR tblOrdenesCensa.IdNo
= @IdNo)
--List 2
ELSE IF @Opcion=2
SELECT dbo.tblO.IdNo FROM dbo.tblO WHERE (@IdNo IS NULL OR
dbo.tblO.IdNo = @IdNo)
END

Actually, I don't get your problem. Do you mean that the following
line is wrong?

<asp:Parameter DefaultValue="2" Name="Opcion" Type="Int32" />
 
Back
Top