The @RowV Values when it reaches the stored procedure on SQL server always gets reset to 0x00 No matter what value I set it to. I am using timestamps to determine if the row has been updated on the server before I apply the new updates.
Thanks for your Help.
Here is the code for the command Object:
cmdUp.CommandText = "udpUpdateDocument"
cmdUp.CommandType = CommandType.StoredProcedure
cmdUp.Parameters.Add("@rc", SqlDbType.Int, 1)
cmdUp.Parameters(0).Direction = ParameterDirection.ReturnValue
cmdUp.Parameters.Add("@DocumentID", SqlDbType.UniqueIdentifier, 1, "DocumentID")
cmdUp.Parameters.Add("@PatientID", SqlDbType.UniqueIdentifier, 1, "PatientID")
cmdUp.Parameters.Add("
@name", SqlDbType.NVarChar, 255, "Name")
cmdUp.Parameters.Add("@Description", SqlDbType.NVarChar, 50, "Description")
cmdUp.Parameters.Add("@Comments", SqlDbType.NVarChar, 100, "Comments")
cmdUp.Parameters.Add("@ProviderID", SqlDbType.SmallInt, 1, "ProviderID")
cmdUp.Parameters.Add("@CreatedBy", SqlDbType.SmallInt, 1, "CreatedBy")
cmdUp.Parameters.Add("@IsReviewed", SqlDbType.Bit, 1, "IsReviewed")
cmdUp.Parameters.Add("@DateCreated", SqlDbType.SmallDateTime, 1, "DateCreated")
cmdUp.Parameters.Add("@DocumentTypeID", SqlDbType.SmallInt, 1, "DocumentTypeID")
cmdUp.Parameters.Add("@FolderTypeID", SqlDbType.SmallInt, 1, "FolderTypeID")
cmdUp.Parameters.Add("@RowV", SqlDbType.Timestamp, 1, "RowV")
cmdUp.Connection = dcEcharts
daECharts.UpdateCommand = cmdUp
AddHandler daECharts.RowUpdating, AddressOf OnRowUpdated_ResyncDocuments
Try
daECharts.Update(dsECharts, "Documents")
Catch ex As Exception
MsgBox(ex.Message)
End Try
Here is the stored Procedure
if exists (select ROUTINE_NAME From INFORMATION_SCHEMA.ROUTINES
Where ROUTINE_TYPE = 'PROCEDURE' AND
ROUTINE_NAME = 'udpUpdateDocument')
Begin
drop proc udpUpdateDocument
END
Go
CREATE PROC udpUpdateDocument
@DocumentID uniqueidentifier,
@PatientID uniqueidentifier,
@name nvarchar(255),
@Description nvarchar(50),
@Comments nvarchar(100),
@ProviderID smallint,
@CreatedBy smallint,
@IsReviewed bit,
@DateCreated datetime,
@DocumentTypeID smallint,
@FolderTypeID smallint,
@RowV timestamp,
@RowOut timestamp OUTPUT
AS
Select * From Documents Where Name =
@name AND DateCreated = @DateCreated AND IsDeleted=0 And PatientID <> @PatientID
IF @@ROWCOUNT = 0
BEGIN
Update Documents
SET IsUpdated =1, Name =
@name, Description = @Description, Comments = @Comments, ProviderID = @ProviderID, CreatedBy = @CreatedBy, IsReviewed = @IsReviewed, FolderTypeID = @FolderTypeID, DateCreated = @DateCreated
WHERE DocumentID=@DocumentID AND PatientID = @PatientID AND IsDeleted = 0 AND RowV<>@RowV
If @@RowCount = 0
BEGIN
Set @ROWOUT = (Select @ROWV)--- For Debug Purposes
RETURN 0
END
ELSE
RETURN 1
END
ELSE
RETURN 0
----- William (Bill) Vaughn wrote: -----
I've done this a number of times so I know it works... let's see some code.
How is the Command object being constructed? How is the SP coded?
--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
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.
__________________________________
TechMD said:
Hi I am impelementing a replication procedure to synchronize local Data
Set record supdate with a SQL Server 2000 DB. I have written a stored
procedure that accepts as one of its paraeters a timestamp parameter to
check the rowversion of the server record before it can apply the update
from the client. However I have noticed that during the Update Command the
values for the rowstamp parameter are for some reasons corrupted and only
show up as NULL or 0x000000000000 instead of the value in the rowversion
column. The strange thing is that when I inspected the values in the
RowUpdating Event Handler the value of the parameter is correct but
somewhere between the point it is packaged to be sent to the database server
and the point where it is unpacked to be passed to the stored procedure it
is being corrupted and turned into a NULL value. Is this a bug in the
ADO.Net sqlCommand object? Or am I doing something wrong. This only happens
with the timestamp parametersa all other parameters work just fine. I love
using timestamp for replication and data conflict resoultion. Does anyone
have any insight as to what I should do?