1

Just starting to learn ASP.NET (C#) and I am using Visual Studio 2008.

I have a stored procedure:

ALTER PROCEDURE dbo.StoredProcedure1    
AS
SET NOCOUNT ON 
SELECT MAX(issue_id) FROM tableb as max_issue_id
RETURN

Which is linked to a sqlDataSource.

How do I retrieve the value from the stored procedure by using the sqlDataSource? Ideally I would like to assign this value to a variable/textbox/label.

2 Answers 2

1

How about something like

<asp:SqlDataSource ID="SqlDataSource1" runat="server"
        ConnectionString="<%$ ConnectionStrings:myConnectionString %>"
        ProviderName="System.Data.SqlClient" 
        SelectCommand="StoredProcedure1" 
        SelectCommandType="StoredProcedure">
        <SelectParameters>
            <asp:ControlParameter ControlID="txtOut" Name="cpOut"               PropertyName="Text" Type="Int32" />
        </SelectParameters>
    </asp:SqlDataSource>
Sign up to request clarification or add additional context in comments.

Comments

0

Thanks Tim.

My final result was:

    <form id="form1" runat="server">
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
        ConnectionString="<%$ ConnectionStrings:ConnectionString %>" 
        SelectCommand="zorro" SelectCommandType="StoredProcedure"></asp:SqlDataSource>
    <br />
    <asp:DataList ID="DataList1" runat="server" DataSourceID="SqlDataSource1">
        <ItemTemplate>
            zorro:
            <asp:Label ID="zorroLabel" runat="server" Text='<%# Eval("zorro") %>' />
            <br />
            <br />
        </ItemTemplate>
     </asp:DataList>
     </form>

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.