473,566 Members | 3,309 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Implementing logical delete within a FormView

I am working on an application that needs to implement logical deletes
instead of removing the records permanently. The logical delete works
by setting 3 fields (deleted flag, date and user). I have been trying
to replace the DeleteCommand query text of the FormView with an UPDATE
statement, but keep getting an error 'Must declare scalar variable
@delete_user'.

The update statement looks like this:

UPDATE [tablename] SET [delete_logical] = N''Y'', [delete_date] =
GETDATE(), [delete_user] = @delete_user WHERE (urn = @original_urn)

The field urn is the key field of the table, and is set correctly. The
field delete_user is available (but invisible) on the FormView, and
gets set to User.Identity.N ame.ToUpper() in the FormView_ItemDe leting
trigger. However, when examining the query executed on the database
through Profiler there is no mention at all of the @delete_user
variable, no definition and no values. This causes the error to occur.
When replacing the variable @delete_user with static text the query
works fine.

Browsing on the net for a solution I came across a two-liner in the
documentation of FormView on DataKeyNames. I tried adding the
delete_user field to the DataKeyNames, but this only results in adding
a definition for original_delete _user to the query for the delete
statement (again via Profiler).

As the (real) update statement in UpdateCommand works fine I suspect
this error has to do with the way the DeleteCommand gets parsed for
variables, and it looks like any variables before the WHERE clause are
ignored.

Does anyone have a solution to this (apart from hand-coding the logical
delete) and/or can anyone confirm that my suspicions on the parsing are
correct.

Many thanks.

Roald.

Nov 28 '06 #1
0 1180

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
4921
by: Daves | last post by:
hi, sorry for re-posting but it's a simple question and ought to have a very simple solution; I am trying to use Findcontrol to grab a Button control within a Formview control: <form ID="Form1" runat="server"> <asp:FormView ID="FormView1" Runat="server"> <ItemTemplate> <asp:Button ID="Button1" runat="server" Text="Breyta"...
4
14311
by: John Bailey | last post by:
I am using a formview with an ObjectDatasource in ASP .Net 2.0. Everything works fine until I try the delete. The ItemDeleting event fires, so I know it should fire my delete method, but instead I get an error: No parameterless constructor defined for this object, and the delete method is never called. Anyone have any ideas?
0
1825
by: TJHerman | last post by:
I have a dropdown list in a Formview that includes a number of fields in the SQLDatasource. I want to be able to get the value of one of the fields in the Datasource that is not the Datatextfield or the Datavaluefield from within a Formview control. I know that I can get the data text field or datavalue field by using the following:...
2
2380
by: sck10 | last post by:
Hello, I have 3 objects: LinkButton GridView FormView The LinkButton is used to open the FormView in Insert mode. The GridView provides a list of products. When the "Select" link is
0
1495
by: TT | last post by:
Hello. I'm working in asp.net and i need to disable the edit/delete functionality from a frmview component. help me.thang you! my ACL sub: Protected Sub Page_Load(ByVal sender As Object, ByVal e As
0
1118
by: Chris | last post by:
I have a formview nested within a formview. It child formview will be the same in both the Insert and Update template in the parent formview. How do place the formview in the templates without copying the formview, something which is not very maintainable. i have tried creating a placeholder and adding the formview programatically but I get...
0
983
by: =?Utf-8?B?cm9kY2hhcg==?= | last post by:
hey all, on the formview you know how there's the capability to delete that record, well what's the best way to add a confirm delete dialog box? thanks, rodchar
0
1682
by: Rafter | last post by:
Hi, I am using a server controls (textbox, dropdownlist, calendar) inside of a form view, it seems that the .Net framework (VB.Net & Net Frame Work 2.0) makes it difficult to access the control properties when embedded inside of a FormView control. What I am trying to do is to enable or disable a textbox control programatically by accessing...
13
5020
by: Tristan Wibberley | last post by:
Hi I've got implementing overloaded operator new and delete pretty much down. Just got to meet the alignment requirements of the class on which the operator is overloaded. But how does one implement operator new/delete I can't see a way to indicate, on delete, how many objects must be destroyed (or how big the space is) - alternatively I...
0
7673
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7584
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7893
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7953
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6263
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5213
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3643
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3626
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2085
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.