Re: What are OleDbParameter names with 'Original_' prefix?



Hi and thanks very much for your reply.

The Data Adapter wizard generated the following UpdateCommand:

UPDATE Questions SET Reference = ?, Status = ?, DateCreated = ? WHERE
(Reference = ?) AND (DateCreated = ? OR ? IS NULL AND DateCreated IS NULL)
AND (Status = ? OR ? IS NULL AND Status IS NULL)

Since the table has a primary key column (Reference), the UPDATE command
doesn't need to include it in the SET list and the WHERE clause doesn't need
the other columns. Therefore I can simplify the command as:

UPDATE Questions SET Status = ?, DateCreated = ? WHERE (Reference = ?)

Is my reasoning correct, and is there anything else I need to add/change to
support this new UPDATE statement?

thanks,

"William (Bill) Vaughn" <billvaRemoveThis@xxxxxxxxxx> wrote in message
news:OLasZPpMHHA.420@xxxxxxxxxxxxxxxxxxxxxxx
This generated code is used to manage update concurrency--to determine if
the row has changed since last accessed. The "original" values are
compared (in the UPDATE) to see if the current values match the original
values. If they do, the UPDATE succeeds and returns 1 row affected, if not
it fails and the Update method throws an exception.

--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
INETA Speaker
www.betav.com/blog/billva
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no
rights.
__________________________________
Visit www.hitchhikerguides.net to get more information on my latest book:
Hitchhiker's Guide to Visual Studio and SQL Server (7th Edition)
and Hitchhiker's Guide to SQL Server 2005 Compact Edition (EBook)
-----------------------------------------------------------------------------------------------------------------------

"JoWilliam" <XjohnXwilliams_Xesq@xxxxxxxxxxxx> wrote in message
news:enr2ch$69v$1@xxxxxxxxxxxxxxxxxxxxxxxx
Hi, I'm new to all this OleDb stuff. I'm using VB in Visual Studio .Net
2003.

The Data Adapter wizard for the OleDbDataAdapter control generates the
following OleDbUpdateCommand object for the query "SELECT Reference,
Status, DateCreated FROM Questions":

Me.OleDbUpdateCommand1.CommandText = "UPDATE Questions SET
Reference = ?, Status = ?, DateCreated = ? WHERE (Reference " & _
"= ?) AND (DateCreated = ? OR ? IS NULL AND DateCreated IS NULL)
AND (Status = ? " & _
"OR ? IS NULL AND Status IS NULL)"
Me.OleDbUpdateCommand1.Connection = Me.dbConn
Me.OleDbUpdateCommand1.Parameters.Add(New
System.Data.OleDb.OleDbParameter("Reference",
System.Data.OleDb.OleDbType.VarWChar, 13, "Reference"))
Me.OleDbUpdateCommand1.Parameters.Add(New
System.Data.OleDb.OleDbParameter("Status",
System.Data.OleDb.OleDbType.VarWChar, 20, "Status"))
Me.OleDbUpdateCommand1.Parameters.Add(New
System.Data.OleDb.OleDbParameter("DateCreated",
System.Data.OleDb.OleDbType.DBDate, 0, "DateCreated"))
Me.OleDbUpdateCommand1.Parameters.Add(New
System.Data.OleDb.OleDbParameter("Original_Reference",
System.Data.OleDb.OleDbType.VarWChar, 13,
System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0,
Byte), "Reference", System.Data.DataRowVersion.Original, Nothing))
Me.OleDbUpdateCommand1.Parameters.Add(New
System.Data.OleDb.OleDbParameter("Original_DateCreated",
System.Data.OleDb.OleDbType.DBDate, 0,
System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0,
Byte), "DateCreated", System.Data.DataRowVersion.Original, Nothing))
Me.OleDbUpdateCommand1.Parameters.Add(New
System.Data.OleDb.OleDbParameter("Original_DateCreated1",
System.Data.OleDb.OleDbType.DBDate, 0,
System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0,
Byte), "DateCreated", System.Data.DataRowVersion.Original, Nothing))
Me.OleDbUpdateCommand1.Parameters.Add(New
System.Data.OleDb.OleDbParameter("Original_Status",
System.Data.OleDb.OleDbType.VarWChar, 20,
System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0,
Byte), "Status", System.Data.DataRowVersion.Original, Nothing))
Me.OleDbUpdateCommand1.Parameters.Add(New
System.Data.OleDb.OleDbParameter("Original_Status1",
System.Data.OleDb.OleDbType.VarWChar, 20,
System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0,
Byte), "Status", System.Data.DataRowVersion.Original, Nothing))

What are the 2 parameters with prefix 'Original_' and suffix '1' used
for?

What are the other 3 parameters prefixed by 'Original_' used for? Are
they used to hold the previous value of the column in case the update
needs to be rolled back?

The table has one primary key column, Reference. Therefore I can change
the update command to:

UPDATE Questions SET Status = ?, DateCreated = ? WHERE (Reference = ?)

If I do this, can I delete the Original_DateCreated1 and Original_Status1
parameters in the above code?

thanks,





.



Relevant Pages

  • Re: What are OleDbParameter names with Original_ prefix?
    ... In a single-user environment you're absolutely correct--well, ... The PK reference deals with that issue. ... the Update method also expects to update the row you originally read--it is ... Since the table has a primary key column, ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: What are OleDbParameter names with Original_ prefix?
    ... Hitchhiker's Guide to Visual Studio and SQL Server ... and Hitchhiker's Guide to SQL Server 2005 Compact Edition (EBook) ... following OleDbUpdateCommand object for the query "SELECT Reference, ... The table has one primary key column, ...
    (microsoft.public.dotnet.framework.adonet)
  • What are OleDbParameter names with Original_ prefix?
    ... The Data Adapter wizard for the OleDbDataAdapter control generates the ... following OleDbUpdateCommand object for the query "SELECT Reference, Status, ... used to hold the previous value of the column in case the update needs to be ... The table has one primary key column, ...
    (microsoft.public.dotnet.framework.adonet)
  • Get Primary Key column
    ... Is there a way in SQL to reference the Primary Key column without using the ... Kind Regards, ...
    (microsoft.public.sqlserver.programming)

Loading