SQL のテーブルから取得したアセットとその情報をテーブルに表示するサイトがあります。必要に応じて、店員がテキストまたはドロップダウン フィールドに新しい情報を入力することで、既存の情報を押して変更できるセクション ボタンがあります。これは、ストアド プロシージャを使用して行われます。作業を確認するまではすべて正常に動作しているように見えますが、何も更新されていません!
情報を編集するためのコードは次のとおりです。
protected void ADD_Click(object sender, EventArgs e)
{
using (SqlConnection connection = new SqlConnection(WebConfigurationManager.ConnectionStrings["DATASYSTEMS"].ConnectionString))
{
SqlCommand cmd = new SqlCommand("UPDATING_ASSETS", connection);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@ASSET_NUMBER", Txtasset_number.Text);
cmd.Parameters.AddWithValue("@MACHINE_NAME", Txtmachine_name.Text);
cmd.Parameters.AddWithValue("@PORT_NUMBER", Txtport_number.Text);
cmd.Parameters.AddWithValue("@BUILDING_NUMBER", DPBUILDING.SelectedValue);
cmd.Parameters.AddWithValue("@ROOM_NUMBER", Txtroom_number.Text);
cmd.Parameters.AddWithValue("@TELEPHONE_NUMBER", Txttelephone_number.Text);
cmd.Parameters.AddWithValue("@FLOOR", Txtfloor.Text);
cmd.Parameters.AddWithValue("@SERIAL", Txtserial.Text);
cmd.Parameters.AddWithValue("@TYPE", DPTYPE.SelectedValue);
cmd.Parameters.AddWithValue("@BRANCH", DPBRANCH.SelectedValue);
cmd.Parameters.AddWithValue("@SECTION", DPSECTION.SelectedValue);
cmd.Parameters.AddWithValue("@USERS", txtuser1.Text);
ClientScript.RegisterClientScriptBlock(this.GetType(), "key", "<script type='text/javascript'>alert('Record has been updated.');window.location='navigation.aspx';</script>");
}
}
protected void dglocaltables_SelectedIndexChanged(object sender, EventArgs e)
{
}
}
更新するはずのストアド プロシージャを次に示します。
CREATE PROCEDURE [dbo].[update_TBL_INFO_1] @ASSET_NUMBER as nvarchar(50), @PORT_NUMBER as nvarchar(50), @MACHINE_NAME as nvarchar(50), @TYPE as nvarchar(50) , @BRANCH as nvarchar(50), @SECTION as nvarchar(50), @BUILDING_NUMBER as nvarchar(50), @ROOM_NUMBER as nvarchar(50), @TELEPHONE_NUMBER as nvarchar (50), @FLOOR as nvarchar (50), @USERS as nvarchar (50), @ID as float (8), @SERIAL as nvarchar (50) as
If (SELECT ASSET_NUMBER FROM dbo.TBL_INFO WHERE ASSET_NUMBER=@ASSET_NUMBER AND [ID]=@ID)=@ASSET_NUMBER
BEGIN
If (SELECT MACHINE_NAME FROM dbo.TBL_INFO WHERE MACHINE_NAME=@MACHINE_NAME AND [ID]=@ID)=@MACHINE_NAME
BEGIN
If (SELECT PORT_NUMBER FROM dbo.TBL_INFO WHERE PORT_NUMBER=@PORT_NUMBER AND [ID]=@ID)=@PORT_NUMBER
BEGIN
If (SELECT [ID] FROM dbo.TBL_INFO WHERE [ID]=@ID)=@ID
BEGIN
UPDATE dbo.TBL_INFO
SET
dbo.TBL_INFO.ASSET_NUMBER = @ASSET_NUMBER,
dbo.TBL_INFO.MACHINE_NAME = @MACHINE_NAME,
dbo.TBL_INFO.PORT_NUMBER = @PORT_NUMBER,
dbo.TBL_INFO.BUILDING_NUMBER = @BUILDING_NUMBER,
dbo.TBL_INFO.ROOM_NUMBER = @ROOM_NUMBER,
dbo.TBL_INFO.TELEPHONE_NUMBER = @TELEPHONE_NUMBER,
dbo.TBL_INFO.[FLOOR]= @FLOOR,
dbo.TBL_INFO.TYPE = @TYPE,
dbo.TBL_INFO.BRANCH = @BRANCH,
dbo.TBL_INFO.[SECTION] = @SECTION,
dbo.TBL_INFO.USERS = @USERS,
dbo.TBL_INFO.[ID] = @ID,
dbo.TBL_INFO.SERIAL = @SERIAL
WHERE dbo.TBL_INFO.ASSET_NUMBER=@ASSET_NUMBER
INSERT INTO dbo.TBL_INFO (ASSET_NUMBER, MACHINE_NAME, PORT_NUMBER, BUILDING_NUMBER, ROOM_NUMBER, TELEPHONE_NUMBER, [FLOOR], TYPE, BRANCH, [SECTION], USERS, SERIAL, [ID]) VALUES (@ASSET_NUMBER, @MACHINE_NAME, @PORT_NUMBER, @BUILDING_NUMBER, @ROOM_NUMBER, @TELEPHONE_NUMBER, @FLOOR, @TYPE, @BRANCH, @SECTION, @USERS, @SERIAL, @ID)
SELECT @ID, ACCESS='VALID'
END
ELSE
BEGIN
SELECT @ID, ACCESS='INVALID'
END
END
ELSE
BEGIN
SELECT ACCESS='RESTRICTED'
END
END
ELSE
BEGIN
SELECT ACCESS='DENIED'
END
END
行く
どこが間違っているのですか?