SQL Stored Procedure fired from C# Code-Behind not working on UPDATE
- by CSSHell
I have a stored procedure called from a C# code-behind. The code fires but the update command does not get performed. The stored procedure, if run directly, works. I think I am having a brain fart. Please help. :)
CODEBEHIND
protected void btnAbout_Click(object sender, EventArgs e)
{
SqlConnection myConnection = new SqlConnection(strConnection);
SqlCommand myCommand = new SqlCommand("spUpdateCMSAbout", myConnection);
myConnection.Open();
myCommand.CommandType = CommandType.StoredProcedure;
myCommand.Parameters.Add("@AboutText", SqlDbType.NVarChar, -1).Value = txtAbout.Text.ToString();
myCommand.ExecuteNonQuery();
myConnection.Close();
}
STORED PROCEDURE
ALTER PROCEDURE fstage.spUpdateCMSAbout
(
@AboutText nvarchar(max)
)
AS
BEGIN
SET NOCOUNT ON;
UPDATE fstage.staticCMS SET About = @AboutText;
END
HTML
<asp:Button ID="btnAbout" runat="server"
Text="Save" CausesValidation="False" onclick="btnAbout_Click"
UseSubmitBehavior="False" />
C# .NET 4.0