Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7842639
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T16:22:07+00:00 2026-06-02T16:22:07+00:00

I am trying to get my head around ASP.NET 4.0 using C# as my

  • 0

I am trying to get my head around ASP.NET 4.0 using C# as my programming language of choice. I am a good SQL developer and so plan to do most of my business logic in SQL. The application will only interact with the database through stored procedures.

In the aspx page I have a datasource for populating a dataview which calls sp ‘season_get_byID’ and for the update ‘season_update’ which takes a number of parameters,

The aspx source shows

    <asp:SqlDataSource ID="dsDetail" runat="server" 
    ConnectionString="<%$ ConnectionStrings:ADR %>" 
        SelectCommand="season_get_by_ID" SelectCommandType="StoredProcedure" 
        UpdateCommand="season_Update" UpdateCommandType="StoredProcedure">
        <SelectParameters>
            <asp:ControlParameter ControlID="GridView1" Name="ID" 
        PropertyName="SelectedValue" Type="Int32" />
        </SelectParameters>
        <UpdateParameters>
            <asp:Parameter Name="ID" Type="Int32" />
            <asp:Parameter Name="Code" Type="String" />
            <asp:Parameter Name="Description" Type="String" />
            <asp:Parameter DbType="Datetime" Name="StartDate" />
            <asp:Parameter DbType="Datetime" Name="EndDate" />
            <asp:Parameter Name="isActive" Type="Byte" />
            <asp:Parameter Name="isCurrent" Type="Byte" />
        </UpdateParameters>
    </asp:SqlDataSource>

Where each asp:Parameter maps to an @Param argument in the stored procedure – so far so good

The stored proc does some validation before trying to do the update. If the validations fail then a RAISERROR(@errmsg,10,1) is raised.

What I can’t work out is where in the aspx.cs code behind file I would try to capture the errors and what the syntax should be: should it be in the after_update event handler and if so it does not appear to be part of e.exception. I know that some of the validation in this routine could be done using the validation classes but this is a learning excercise in the manipulating the environment rather than final production code i.e. I am trying to understand what is possible, rather than what is ‘correct’

text for stored proc is below.

ALTER Procedure [dbo].[season_Update] 
    (
        @ID int,
        @Code nvarchar(10), 
    @Description nvarchar(50), 
    @StartDate date, 
    @EndDate date, 
    @isActive tinyint, 
    @isCurrent tinyint
)
as
DECLARE @ERR nvarchar(max) = ''

IF (SELECT count(*) FROM season WHERE ID = @ID) = 0 
BEGIN
SET @ERR = @ERR + '|Season Doesn''''t exist'
END

/*validate that season code and description are not blank*/
IF (@Code is null 
or
ltrim(rtrim(@Code)) = ''
)
BEGIN
set @ERR =+ '|Season Code cannot be blank'
END

IF @ERR = ''
BEGIN
IF (@Description is null 
    or
    ltrim(rtrim(@Description)) = ''
    )
BEGIN
    set @ERR =+ '|Season Description cannot be blank'
END

/*validate that the season code does not already exist on a different ID*/
IF (SELECT count(*) FROM season WHERE Code = ltrim(rtrim(upper(@CODE))) and 
       ID <> @ID) > 0 
BEGIN
    SET @ERR =+ '|Season Code ' + @Code + 'already exists'
END

/*validate that the start date is before the end date*/
IF @Startdate > @Enddate
BEGIN
    SET @ERR =+ '|Start Date cannot be Before End Date'
END
END

IF @ERR = ''
BEGIN
BEGIN TRY
UPDATE Season
    SET Code = ltrim(rtrim(upper(@Code))), 
        Description = Ltrim(rtrim(@Description)), 
        StartDate = @StartDate, 
        EndDate = @EndDate, 
        isActive = @isActive, 
        isCurrent = @isCurrent
WHERE
        ID = @ID    
END TRY
BEGIN CATCH
RAISERROR(N'There was a problem',10,1)
END CATCH
END

IF @ERR <> ''
BEGIN
RAISERROR(@ERR,10,1)
END
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T16:22:08+00:00Added an answer on June 2, 2026 at 4:22 pm

    Microsoft have an article on this, How to Retrieve Values in SQL Server Stored Procedures, albeit in Visual Basic. This should give you an idea on how to resolve your problem.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

essentially what I'm trying to do is get my head around Microsoft's ASP.NET MVC
I'm trying to get my head around how one would unit test an ASP.NET
I'm currently trying to get my head around WCF services for an ASP.NET dev
I'm new to web services in ASP.NET. Been trying to get my head around
Trying to get my head around backbone.js. This example is using Backbone Boilerplate and
Trying to get my head around using functions as arguments to methods. For a
I'm trying to get my head around asynchronous programming in C# 5 and the
trying to get my head around using Lambda expressions to fetch data from my
trying to get my head around Feedzirra here. I have it all setup and
Trying to get my head around how to integrate fancyBox with an aspx c#

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.