Here is the situation that I have to insert profile photos in the SQL table. But here are 2 scenarios the condition
if user is inserting photo and data from front end. Its working perfectly fine.
if user is skip the photo and just inserting his biography then in that case the default image should be inserted by default. I tried to do in front end Just adding dummy image in if else condition, but in DMZ server for some reason this is creating problem, on local server its working good. Here is the Query...
ALTER PROCEDURE [dbo].[SavePhysicianBiodata] -- Add the parameters for the stored procedure here @ID int, @Physician_Bio nvarchar(MAX), @Physician_Mnemonic nvarchar(MAX), @Physician_Image image, @Physician_ImageType nvarchar(MAX), @Physician_ImageFileName nvarchar(MAX) AS BEGIN -- SET NOCOUNT ON added to prevent extra result sets from -- interfering with SELECT statements. SET NOCOUNT ON; if( @ID is null OR @ID='') begin --if not image then deafult image will be applied if((@Physician_ImageType is null or @Physician_ImageType='') and (@Physician_ImageFileName is null or @Physician_ImageFileName='') ) begin insert into Physician_Biodata(Physician_Bio, Physician_Mnemonic) values(@Physician_Bio, @Physician_Mnemonic) set @ID = SCOPE_IDENTITY() update [dbo].[Physician_Biodata] set Physician_Image=@Physician_Image, Physician_ImageType=@Physician_ImageType, Physician_ImageFileName=@Physician_ImageFileName where ID=@ID end else begin -- Insert statements for procedure here when user adds photo as well insert into Physician_Biodata(Physician_Bio, Physician_Mnemonic, Physician_Image, Physician_ImageType, Physician_ImageFileName) values(@Physician_Bio, @Physician_Mnemonic, @Physician_Image,@Physician_ImageType,@Physician_ImageFileName) end end else begin update [dbo].[Physician_Biodata] set Physician_Bio=@Physician_Bio, Physician_Mnemonic=@Physician_Mnemonic, Physician_Image=@Physician_Image, Physician_ImageType=@Physician_ImageType, Physician_ImageFileName=@Physician_ImageFileName where ID=@ID end END
In this query I also tried insert query which is given below
insert into Physician_Biodata(ID, Physician_Image, Physician_ImageType, Physician_ImageFileName)
select @ID, dd.Physician_Image,dd.Physician_ImageType,dd.Physician_ImageFileName from DefaultImage as dd
join Physician_Biodata
on Physician_Biodata.Physician_ImageFileName = dd.Physician_ImageFileName
where Physician_Biodata.ID = @ID
but getting error during execute procedure
Msg 544, Level 16, State 1, Procedure dbo.SavePhysicianBiodata, Line 35 [Batch Start Line 2]
Cannot insert explicit value for identity column in table 'Physician_Biodata' when IDENTITY_INSERT is set to OFF.
If somebody can help me it would be great.. Thanks in advance.