Reputation: 25
I'm developing a project in which I have to use a database to store data from a cinema. One of the tables stores some movies data(movie name, duration actors, etc) and it has a image column; I left it null so that I could take care of the login first and then inserted the ovies but didn't insert the image, and now when I try to insert the image it gives this error.
The multi-part identifier "Filmes.Titulo_Filme" could not be bound.
The code I'm using to insert the image is this:
insert into Filmes (Imagem) select * from OPENROWSET(BULK N'F:\RC\RC8\Projecto\ShikiHD_ASP\ShikiHD_ASP\Images\bohemianrhapsody.jpeg', SINGLE_BLOB) as image where Filmes.Titulo_Filme = 'Bohemian Rhapsody'
Any help is much appreciated.
EDIT: I tried to update the column since I already had all the other columns filled and it still didn't work, but now it gives another error.
String or binary data would be truncated.
The statement has been terminated.
The code for the update:
update Filmes set Imagem = (select * from OPENROWSET(BULK N'F:\RC\RC8\Projecto\ShikiHD_ASP\ShikiHD_ASP\Images\bohemianrhapsody.jpeg', SINGLE_BLOB) as image) where Filmes.Titulo_Filme = 'Bohemian Rhapsody'
Upvotes: 0
Views: 857
Reputation: 39
Please try to run following queries separately. So you will come to know which query throws error. FIRST QUERY
SELECT * FROM Filmes WHERE Filmes.Titulo_Filme = 'Bohemian Rhapsody'
SECOND QUERY
SELECT BulkColumn FROM OPENROWSET(BULK N'F:\RC\RC8\Projecto\ShikiHD_ASP\ShikiHD_ASP\Images\bohemianrhapsody.jpeg' , SINGLE_BLOB) AS x
Upvotes: 1
Reputation: 39
As per your statement you have already inserted data in all the fields other than image
field of Filmes
table.
So instead of inserting you need to update the column as follows. Also you need to ensure brackets are added at proper places.
UPDATE Filmes
SET Imagem =
(SELECT BulkColumn FROM OPENROWSET(BULK N'F:\RC\RC8\Projecto\ShikiHD_ASP\ShikiHD_ASP\Images\bohemianrhapsody.jpeg' , SINGLE_BLOB) AS x)
WHERE Filmes.Titulo_Filme = 'Bohemian Rhapsody'
Upvotes: 1
Reputation: 1270773
This is your query:
insert into Filmes (Imagem)
select *
from OPENROWSET(BULK N'F:\RC\RC8\Projecto\ShikiHD_ASP\ShikiHD_ASP\Images\bohemianrhapsody.jpeg', SINGLE_BLOB) as image
where Filmes.Titulo_Filme = 'Bohemian Rhapsody'
Filmes
is not defined. image
is. So perhaps you mean:
insert into Filmes (Imagem)
select imagen
from OPENROWSET(BULK N'F:\RC\RC8\Projecto\ShikiHD_ASP\ShikiHD_ASP\Images\bohemianrhapsody.jpeg', SINGLE_BLOB) as image
where image.Titulo_Filme = 'Bohemian Rhapsody';
Or perhaps you really want an update
:
update filmes
set imagem = i.image
from OPENROWSET(BULK N'F:\RC\RC8\Projecto\ShikiHD_ASP\ShikiHD_ASP\Images\bohemianrhapsody.jpeg', SINGLE_BLOB) as i(image)
where filmes.Titulo_Filme = 'Bohemian Rhapsody';
Upvotes: 2