Avatar billede simsen Mester
23. juni 2003 - 19:46 Der er 15 kommentarer og
1 løsning

Hente bestemte billeder fra database

Hejsa alle :-)

Jeg har en hjemmeside, hvor jeg henter billeder fra min database (access) ind med følgende:

select [File Data],[Content Type] from Files where ID = " & _ID

Problemet er at den henter alle billederne i tabellen - men nu er det sådan, at jeg kun vil have billederne der starter med th_(en eller anden tekst) ind - hvordan gør jeg det?

simsen :-)
Avatar billede terry Ekspert
23. juni 2003 - 19:57 #1
select [File Data],[Content Type] from Files where ID = " & _ID & " AND [File Date Like 'th_" & "en eller anden tekst" & "*'"
Avatar billede terry Ekspert
23. juni 2003 - 19:58 #2
I am assuming that [File Data] is the picture field

Little correct:
select [File Data],[Content Type] from Files where ID = " & _ID & " AND [File Data] Like 'th_" & "en eller anden tekst" & "*'"
Avatar billede simsen Mester
23. juni 2003 - 20:04 #3
Hi Terry

File Data is the picture - but I want to have all the pictures be listing which name starts with th_
Avatar billede terry Ekspert
23. juni 2003 - 20:08 #4
select [File Data],[Content Type] from Files where [File Data] Like 'th_" & "en eller anden tekst" & "*'"
Avatar billede terry Ekspert
23. juni 2003 - 20:09 #5
You have to replace "en eller anden tekst" with what ever text you want to use
Avatar billede simsen Mester
23. juni 2003 - 20:15 #6
Hi terry

Sorry but I have not explained myself good enough

I have 4 pictures in my database

the names of the picuteres I have saved under the field File Name and called them:
1.jpg
th_1.jpg
2. jpg
th_2.jpg

The binary data for each picture is saved in the field File Data

When I use
select [File Data],[Content Type] from Files where ID = " & _ID
Then all the pictures is shown - but I only want to see the pictures wich names starts with th_
Avatar billede terry Ekspert
23. juni 2003 - 20:17 #7
select [File Data],[Content Type] from Files where [File Name] Like 'th_" & "en eller anden tekst"
Avatar billede terry Ekspert
23. juni 2003 - 20:19 #8
simsen>Just a note here. Although you can have the files INSIDE the database then it is best to have your files in a folder an dNOT in the dB. Picture files fill quite a lot and Access does have its limitations!
Avatar billede simsen Mester
23. juni 2003 - 20:21 #9
terry

I know - it is only a few pictures I don't want anyone to get there fingers on - they should only be able to see them ;-)
Avatar billede terry Ekspert
23. juni 2003 - 20:24 #10
OK, then it should be no problem
Avatar billede simsen Mester
23. juni 2003 - 20:33 #11
I didn't work theres - so I tried this

"select [ID],[File Name],[File Size],[Content Type]," & _
        "[Kategori] from Files Where [File Name] Like 'th_*" & _
        "order by [Kategori] asc", connStr, 3, 4

But If I do this - It sais there were no files found - how can I make the * (because I don't know how many or which names they have?
Avatar billede terry Ekspert
23. juni 2003 - 20:43 #12
You can try making the query in Access first to make sure it does give a result.

Then you can try by first selecting ALL fields and all records to make sure everything else is working too.

"SELECT * FROM Files"
Avatar billede simsen Mester
23. juni 2003 - 20:45 #13
terry

Regarding to the above - when I writes
"select [ID],[File Name],[File Size],[Content Type]," & _
        "[Kategori] from Files Where [File Name] Like 'th_1.jpg" & _
        "order by [Kategori] asc", connStr, 3, 4

it shows me correctly the picture for th_1.jpg

But my problem is - that there is several th_ pictures - and I don't know the hole name for them alle - so it should list alle the pictures which starts with th_
Avatar billede terry Ekspert
23. juni 2003 - 20:52 #14
You should be able to use

Like 'th_*' "
or you can also try
Like 'th_%' "
Avatar billede simsen Mester
23. juni 2003 - 20:53 #15
terry

Thank you thank you very much - you saved my day - it was 'th_%'

simsen :-)
Avatar billede terry Ekspert
23. juni 2003 - 20:58 #16
strange because in Access the * is the wildcard characater but it seems that in ASP it must be a % not to woory we got there in the end :o)

og tak !
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Dyk ned i databasernes verden på et af vores praksisnære Access-kurser

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester