SQL Server Stored Procedure Update not working with ASP.Net C# GridView RowUpdating

后端 未结 3 496
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-26 02:04

I am having an issue but I am not getting any errors thrown. What\'s happening is that I have a stored procedure that is driving my update but I am unable to get the gridview to

3条回答
  •  我在风中等你
    2021-01-26 02:37

    Stored Procedures:

    ALTER PROCEDURE [dbo].[CompDev_Select]
    AS
        BEGIN
            SET NOCOUNT ON;
    
            SELECT  [WC].[CompID]
                  , [WC].[NewDevCount]
                  , [WC].[DevelopmentName]
                  , [WC].[City]
                  , [WC].[State]
                  , [WC].[ZipCodeofNewDev]
                  , [WC].[ProjectStatus]
                  , [WC].[ShoppingCenter]
                  , [WC].[ProjectStartDate]
                  , [WC].[ProjectDescription]
                  , [WC].[ProposedAnchorTenants]
                  , [WC].[GLA]
                  , [WC].[EstCompDate]
                  , [WC].[Developer]
                  , [WC].[BusinessUnit]
                  , [WC].[BU]
                  , [WC].[CenterName]
                  , [WC].[MSA]
                  , [WC].[BrixmorMSARank]
                  , [WC].[Count]
                  , [WC].[Region]
                  , [WC].[DistancefromNewDev]
            FROM    [dbo].[WestCompetition] AS WC
    
            SET NOCOUNT OFF;
        END
    GO
    
    
    
    ALTER PROCEDURE [dbo].[CompDev_Update]
        ( @CompID INT
        , @NewDevCount NCHAR(10) = NULL
        , @DevelopmentName NVARCHAR(255) = NULL
        , @City NVARCHAR(255) = NULL
        , @State NVARCHAR(255) = NULL
        , @ZipCodeofNewDev NCHAR(10) = NULL
        , @ProjectStatus NVARCHAR(255) = NULL
        , @ShoppingCenter NVARCHAR(255) = NULL
        , @ProjectStartDate FLOAT = NULL
        , @ProjectDescription NVARCHAR(255) = NULL
        , @ProposedAnchorTenants NVARCHAR(255) = NULL
        , @GLA NCHAR(10) = NULL
        , @EstCompDate FLOAT = NULL
        , @Developer NVARCHAR(255) = NULL
        , @BusinessUnit NCHAR(10) = NULL
        , @BU NCHAR(10) = NULL
        , @CenterName NVARCHAR(255) = NULL
        , @MSA NVARCHAR(255) = NULL
        , @BrixmorMSARank NCHAR(10) = NULL
        , @Count NCHAR(10) = NULL
        , @Region NVARCHAR(255) = NULL
        , @DistancefromNewDev NCHAR(10) = NULL )
    AS
        BEGIN
            SET NOCOUNT ON;
    
            UPDATE  WC
            SET     NewDevCount = @NewDevCount
                  , DevelopmentName = @DevelopmentName
                  , City = @City
                  , [State] = @State
                  , ZipCodeofNewDev = @ZipCodeofNewDev
                  , ProjectStatus = @ProjectStatus
                  , ShoppingCenter = @ShoppingCenter
                  , ProjectStartDate = @ProjectStartDate
                  , ProjectDescription = @ProjectDescription
                  , ProposedAnchorTenants = @ProposedAnchorTenants
                  , GLA = @GLA
                  , EstCompDate = @EstCompDate
                  , Developer = @Developer
                  , BusinessUnit = @BusinessUnit
                  , BU = @BU
                  , CenterName = @CenterName
                  , MSA = @MSA
                  , BrixmorMSARank = @BrixmorMSARank
                  , [Count] = @Count
                  , Region = @Region
                  , DistancefromNewDev = @DistancefromNewDev
            FROM    [dbo].[WestCompetition] AS WC
            WHERE   ( [WC].CompID = @CompID );
    
            SET NOCOUNT OFF;
        END
    GO
    
    
    ALTER PROCEDURE [dbo].[CompDev_Insert]
        ( @NewDevCount NCHAR(10) = NULL
        , @DevelopmentName NVARCHAR(255) = NULL
        , @City NVARCHAR(255) = NULL
        , @State NVARCHAR(255) = NULL
        , @ZipCodeofNewDev NCHAR(10) = NULL
        , @ProjectStatus NVARCHAR(255) = NULL
        , @ShoppingCenter NVARCHAR(255) = NULL
        , @ProjectStartDate FLOAT = NULL
        , @ProjectDescription NVARCHAR(255) = NULL
        , @ProposedAnchorTenants NVARCHAR(255) = NULL
        , @GLA NCHAR(10) = NULL
        , @EstCompDate FLOAT = NULL
        , @Developer NVARCHAR(255) = NULL
        , @BusinessUnit NCHAR(10) = NULL
        , @BU NCHAR(10) = NULL
        , @CenterName NVARCHAR(255) = NULL
        , @MSA NVARCHAR(255) = NULL
        , @BrixmorMSARank NCHAR(10) = NULL
        , @Count NCHAR(10) = NULL
        , @Region NVARCHAR(255) = NULL
        , @DistancefromNewDev NCHAR(10) = NULL )
    AS
        INSERT  INTO [dbo].[WestCompetition]
                ( [NewDevCount]
                , [DevelopmentName]
                , [City]
                , [State]
                , [ZipCodeofNewDev]
                , [ProjectStatus]
                , [ShoppingCenter]
                , [ProjectStartDate]
                , [ProjectDescription]
                , [ProposedAnchorTenants]
                , [GLA]
                , [EstCompDate]
                , [Developer]
                , [BusinessUnit]
                , [BU]
                , [CenterName]
                , [MSA]
                , [BrixmorMSARank]
                , [Count]
                , [Region]
                , [DistancefromNewDev] )
        VALUES  ( @NewDevCount
                , @DevelopmentName
                , @City
                , @State
                , @ZipCodeofNewDev
                , @ProjectStatus
                , @ShoppingCenter
                , @ProjectStartDate
                , @ProjectDescription
                , @ProposedAnchorTenants
                , @GLA
                , @EstCompDate
                , @Developer
                , @BusinessUnit
                , @BU
                , @CenterName
                , @MSA
                , @BrixmorMSARank
                , @Count
                , @Region
                , @DistancefromNewDev );
    GO
    
    
    ALTER PROCEDURE [dbo].[CompDev_Delete] ( @CompID INT )
    AS
        BEGIN
            SET NOCOUNT ON;
    
            DELETE  WC
            FROM    [dbo].[WestCompetition] AS WC
            WHERE   [WC].[CompID] = @CompID
    
            SET NOCOUNT OFF;
        END
    GO
    

    Front-end Code:

    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
    
    
    
    
    
        
    
    
        
    No data was returned.
     

    So - what I did: I set up a simple listview, hooked to the connection string in the web.config. The listview has a SQL Data Source hooked to that connection string, and it uses the stored procedures above for its data CRUD operations. I even added in your styles so the LV looks like your GV looked.

    I'm ok with it if you don't accept this as your answer, since I didn't technically fix your gridview issues, instead replacing them. That said, using this solution would make your work move right along. :)

提交回复
热议问题