Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 problem in saving file as type image in SP

Author  Topic 

mfghazi
Starting Member

5 Posts

Posted - 2009-03-12 : 09:49:33
Hello All,

I have stored procedure which is accepting a file as type image. Inside this SP, I am calling another stored procedure which is saving this file in a table. Here is the code snipit:


ALTER PROCEDURE spMainStoredProcedure
(
@MyID as int,
@MyName as varchar(100),
@MyFileName as varchar(255),
@MyFileDocument as image,
)
as
begin
declare @Identity int
insert into MyTable (MyID, MyName) values (@MyID, @MyName)

set @Identity = @@Identity

exec spUploadFile @MyFileID = @Identity, @FileName = @MyFileName, @FileDocument = @MyFileDocument

end


When I call spMainStoredProcedure from my ASP.NET page, I get an error that @Identity is null. It means that it didn't even execute the insert statement. So apparently, the problem is in passing the file as image. But if I call spUploadFile directly from my web page and pass all the parameters, everything works fine.

Please comment.

mfghazi
Starting Member

5 Posts

Posted - 2009-03-12 : 11:48:49
Please let me know if additional information is needed.
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-03-12 : 11:50:23
set @Identity = SCOPE_IDENTITY()




E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-03-12 : 13:18:41
http://blog.sqlauthority.com/2007/03/25/sql-server-identity-vs-scope_identity-vs-ident_current-retrieve-last-inserted-identity-of-record/
Go to Top of Page
   

- Advertisement -