Click here to Skip to main content
15,906,816 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi

I am working on an application of uploading files and if the file already exists in the database then it updates(rewrites) the information into the database.

When I debugged I found that while updating the values fails. and transactin is rolled back
Please any one can help.
SQL
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER Procedure [dbo].[IMS_NB_EMRUP_Process_Update]
	@LogGuid uniqueidentifier, 
	@FileGuid uniqueidentifier, 
	@Clients int, 
	@Completed int, 
	@Prepared int, 
	@DateTime datetime, 
	@UploadedByIMSUserId char(25),
	@StartTime datetime,
	@FileName nvarchar(250)
AS


update IMS_eMRUpload_Process SET 
					Clients=@Clients, 
					Completed=@Completed, 
					Prepared=@Prepared, 
					DateTime=@DateTime,
					UploadedByIMSUserId=@UploadedByIMSUserId,
					StartTime=@StartTime,
					FileName=@FileName
					

		where LogGuid=@LogGuid and FileGuid=@FileGuid
Posted
Updated 4-Jul-13 0:04am
v5
Comments
Pheonyx 28-Jun-13 5:24am    
Does the SQL statement cause any exceptions to be thrown?
If you manually run the statement in SSMS does it work or fail?
babli3 28-Jun-13 5:27am    
Hi It works fine when i run the stored procedure in sql management studio.
But when I am debugging in visual studio , I found the exception "Update fails in inserting the values". Thanks

1 solution

I'm assuming that you mean that your code throws the ApplicationException, rather than actually rolls back, given that you aren't showing any transaction processing in that code, so the term "rollback" is not applicable.

If so, then the most likely thing is as your message says: the LogId and FileId combination has not been found in the database, so no update was performed.
Either use the debugger to check the values you are passing through as _logGuid and _fileGuid or print them to a log file somewhere, then check your DB for matching data. I can only assume that one or other of them is not what you think it is.
 
Share this answer
 
Comments
babli3 28-Jun-13 5:32am    
Thanks I will check that.
OriginalGriff 28-Jun-13 5:51am    
You're welcome!
babli3 4-Jul-13 6:05am    
Hi,
Sorry still couldnt fix the problem. when i debugged i found _fileGuid has null value... please help if you can...Thanks
OriginalGriff 4-Jul-13 6:12am    
Then you need to look at your C# code to find out why it has a null value - I can't help you because I can't access your HDD or see your screen... :laugh:
babli3 4-Jul-13 6:20am    
Yeah I understand thanks

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900