sqlDataSource + Store Procedure + pameters IF

  • Thread starter Don Quijote de Nicaragua
  • 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
 
G

Guest

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" />
 
D

Don Quijote de Nicaragua

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" />
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,070
Latest member
BiogenixGummies

Latest Threads

Top