0

ストア プロシージャと C# を使用して Web フォームを更新しようとしている Visual Studio の初心者です。コードに問題があります。

C# コード

protected void Btn_update_Click(object sender, EventArgs e)
{
        SqlConnection conn = new SqlConnection(@"Data Source=mac\SQLEXPRESS;initial K Catalog=outlines_db;integrated Security=True");
        SqlCommand cmd = new SqlCommand("update_outlines", conn);
        cmd.CommandText = "update_outlines";
        cmd.CommandType = CommandType.StoredProcedure;
        cmd.Parameters.AddWithValue("@title", txt_title.Text);
        cmd.Parameters.AddWithValue("@code", txt_code.Text);
        cmd.Parameters.AddWithValue("@instructor", txt_instructor.Text);
        cmd.Parameters.AddWithValue("@credit", txt_credits.Text);
        cmd.Parameters.AddWithValue("@topic1", txt_topic1.Text);
        cmd.Parameters.AddWithValue("@topic2", txt_topic2.Text);
        cmd.Parameters.AddWithValue("@topic3", txt_topic3.Text);
        cmd.Parameters.AddWithValue("@topic4", txt_topic4.Text);
        cmd.Parameters.AddWithValue("@topic5", txt_topic5.Text);
        conn.Open();
        cmd.ExecuteNonQuery();
        conn.Close();
        Response.Redirect("Grid_update.aspx");
}

ストアド プロシージャ

ALTER PROCEDURE update_outlines 
    -- Add the parameters for the stored procedure here
        (
    @title varchar(100),
    @code varchar(100),
    @instructor varchar(100),
    @credit varchar(100),
    @topic1 varchar(200),
    @topic2 varchar(200),
    @topic3 varchar(200),
    @topic4 varchar(200),
    @topic5 varchar(200)

    )

AS
BEGIN
    -- SET NOCOUNT ON added to prevent extra result sets from
    -- interfering with SELECT statements.
    SET NOCOUNT ON;

    -- Insert statements for procedure here
    UPDATE outline
    SET

    [course_title]= @title,
        [instructor]=@instructor,
        [credit] =@credit,
        [topic1]=@topic1,
        [topic2]=@topic2,
        [topic3]=@topic3,
        [topic4]=@topic4,
        [topic5]=@topic5
        WHERE
        [course_code]= @code

END
GO
4

0 に答える 0