Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Delete Command is messing up?

Status
Not open for further replies.

tqeonline

MIS
Oct 5, 2009
304
US
I have two delete statements that i have converted into Update statements. So when they hit delete it does a logical delete instead of a physical delete. I have a Delete column in the DB that just gets updated to a "1" when it is deleted.

Here are the statements:
Deleting a Device:
Code:
            DeleteCommand="UPDATE [AMA_DEVICE] SET [DELETED] = '1' WHERE [ID] = @ID; INSERT INTO [AMA_Device_History] ([USER_ID], [DEVICE_ID], [ACTION], [DATE_TIME]) VALUES (@USER_ID, @DEVICE_ID, 'DELETED', dateadd(hour,-2,getdate()))" 
            <DeleteParameters>
                <asp:Parameter Name="DEVICE_ID" Type="String" />
                <asp:Parameter Name="MANUFACTURER" Type="String" />
                <asp:Parameter Name="MODEL" Type="String" />
                <asp:Parameter Name="CARRIER" Type="String" />
                <asp:Parameter Name="STATUS" Type="String" />
                <asp:Parameter Name="USER_ID" Type="String" />
                <asp:Parameter Name="LOCATION" Type="String" />
                <asp:Parameter Name="NOTES" Type="String" />
                <asp:Parameter Name="ID" Type="Int32" />
            </DeleteParameters>

Deleting a User:
Code:
DeleteCommand="INSERT INTO [AMA_User_History] ([USER_ID], [ACTION], [DATE_TIME]) VALUES (@USER_ID, 'Deleted', dateadd(hour,-2,getdate())); UPDATE [AMA_User] SET [DELETED] = '1' WHERE [ID] = @ID" 
            <DeleteParameters>
                <asp:Parameter Name="ID" Type="Int32" />
                <asp:Parameter Name="USER_ID" Type="String" />
            </DeleteParameters>

what i am trying to do is perform the Update then perform an Insert into an audit history that I have. The error that gets prompted for both deletes is "Must declare the scalar variable @USER_ID" - I have it declared in my DeleteParameters

Any Ideas?

- Matt

"If I must boast, I will boast of the things that show my weakness"

- Windows 2003 Server, 98 SE, XP
- VB.NET, VSTS 2010, ASP.NET, EXCEL VBA, ACCESS, SQL 2008
 
I fixed it by making both KeyDataFields = "USER_ID" and updating the queries accordingly.

- Matt

"If I must boast, I will boast of the things that show my weakness"

- Windows 2003 Server, 98 SE, XP
- VB.NET, VSTS 2010, ASP.NET, EXCEL VBA, ACCESS, SQL 2008
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top