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 2000 Forums
 Transact-SQL (2000)
 Problems with images.

Author  Topic 

ados_dani
Starting Member

1 Post

Posted - 2004-04-16 : 06:08:39
Hello every body, first sorry my bad english.

We're developing an aplicatión to store images, the data base has two tables one for commun data an another to images.

The code (visual basic 6) calls the fist procedure "insertar_cabeceras" and this procedure calls the procedure "insertar_imagenes" as many times as images have that document.

THE PROBLEM IS that it works in local machine, but when we execute it in the server, it looks correctly the records is written correctly but the image isn´t write or we can´t take it.

Thanks

Dani

the code is listed below

CREATE PROCEDURE sp_Insertar_cabecera
@User varchar(20), --usuario
@Pag_T varchar(2), --Página total
@Cam1 varchar(20), --campo1
@Cam2 varchar(20), --campo2
@Cam3 varchar(20), --campo3
@Cam4 varchar(20), --campo4
@Resol varchar(3), --resolucion
@Tam_Ima varchar(10), --tamaño de imagen
@Nom_Med varchar(10), --nombre del archivo de la imagen
--Número de imágenes
@CantImagenes int,
-- Otros parámetros
@srvname2 varchar (30),
@login2 varchar (30),
@password2 varchar (30),
@dbname2 varchar (30),
@tbname2 varchar (30),
@colname2 varchar (30),
@filename2 varchar (30)--path to the temporal files
--@whereclause2 varchar (40),
--@direction2 char(1),--Direccion de entrada o de salida
--@out int OUTPUT--ID de registro de vuelta
AS
declare @Id_refer as int
declare @contador as int
declare @Where as varchar(200)
declare @strTemp as varchar(79)
--Metemos el registro de Cabecera
INSERT INTO Cabeceras VALUES(getdate(),@User,@Pag_T,@Cam1,@Cam2,@Cam3,@Cam4,@Resol,@Tam_Ima,@Nom_Med)
select @id_refer = @@IDENTITY
print @id_refer
select @contador=1
SELECT @Where = 'WHERE Id_Registro = '+CAST( @Id_refer AS VARCHAR)
print @Where
print cast(@cantimagenes as varchar)+ ': number of images'
WHILE (@contador<= @cantImagenes)
BEGIN
SELECT @Where = 'WHERE Id_Registro = '+CAST( @Id_refer AS VARCHAR)+' AND [N_Pag] = '+ CAST( @contador AS VARCHAR)
SELECT @strTemp= @filename2 + CAST(@contador AS VARCHAR) +'.jpg'
Insert into Imagenes values (@id_refer,@contador,0x0)

exec sp_insertar_imagen
@srvname = @srvname2,
@login = @login2,
@password = @password2,
@dbname = @dbname2,
@tbname = @tbname2,
@colname = @colname2,
@filename = @strTemp,
@WhereClause = @Where,
@direction= 'I'
select @contador = @contador +1

END

CREATE PROCEDURE sp_insertar_imagen (
@srvname varchar (30),
@login varchar (30),
@password varchar (30),
@dbname varchar (30),
@tbname varchar (30),
@colname varchar (30),
@filename varchar (30),
@whereclause varchar (40),
@direction char(1))
AS
DECLARE @exec_str varchar (255)
SELECT @exec_str =
'C:\Ados\comun\SQLejec\textcopy /S ' +
@srvname + ' /U ' + @login + ' /P ' + @password + ' /D ' +
@dbname + ' /T ' + @tbname + ' /C ' + @colname + ' /W "' +
@whereclause + '" /F ' + @filename + ' /' + @direction
EXEC master..xp_cmdshell @exec_str
print 'asdsad'
GO

AndrewMurphy
Master Smack Fu Yak Hacker

2916 Posts

Posted - 2004-04-16 : 07:02:58
Without delving into the specifics of your problem, the best advice you will get here is "NOT to store images in SQL Server, but to store the files within 'LAN directory structures' and save the 'path of the image' within SQL Server"....search here for previous discussions on this topic


In relation to this specific problem....(for example) C:\ on your PC is not the same C:\ as seen from the server....and your SQL code runs in the context/control of the server.....(so you may be pointing/looking in the wrong area)

You may also have a file-access permissions issue to resolve....
Go to Top of Page
   

- Advertisement -