October 25, 2008 at 11:49 pm
Can anyone tell how can i set reference in sql 2005 of images saved in the server folder.(i need query)
i want display images in web application through datalist control of asp.
October 26, 2008 at 3:45 am
Can you explain in more detail?
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
October 26, 2008 at 3:56 am
There are 100+ images which i want to display in datalist control of asp. Those images are saved in web application which i have created i.e in solution explorer of Visual studio 2005. I want to connect datalist control with sql server 2005 which has reference to images saved in web application. I dono how can i save reference in sql table which will refer to images.
October 26, 2008 at 4:16 am
Two options. Have a column in the table that stored the full path and filename, or you can put the entire picture in the table using a varbinary(max) column
If that doesn't help, please give us more information about what you're doing. Database table structure, etc.
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
October 26, 2008 at 4:23 am
This is wat my question how can i store full path nad filename in table??? I dono query for that.
Secondly, i have inserted image in table with data type as varbinary(max) and tried to retrieve through datalist control but was unsuccessful.
October 26, 2008 at 5:09 am
Are you looking for a way to automatically get the names and paths of the images that are in the file system into the table? Will it be a once-off load, or will you have to repeat it again and again?
There's no direct way to query the filesystem. You could use xp_cmdshell (if it's enabled) to get a directory listing into a table. It will need cleaning up before you can use it though. If xp_cmdshell isn't enabled, you can put the directory listing into a text file and either change that into insert statements, or insert the whole thing into a table and then clean it up.
To use xp_cmdshell
CREATE TABLE #CmdShellOutput (direntry VARCHAR(2000))
INSERT INTO #CmdShellOutput
EXEC master.sys.xp_cmdshell 'DIR < Directory of images >'
To get the directory listing into a text file (dirinfo.txt)
From the command prompt
DIR < Directory of images > > dirinfo.txt
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
October 26, 2008 at 12:32 pm
GilaMonster (10/26/2008)
There's no direct way to query the filesystem.
i would say this is best done through the web pages code
-----------------------------------------------------------------------------------------------------------
"Ya can't make an omelette without breaking just a few eggs" 😉
October 27, 2008 at 6:55 am
What you actually have to store is the relative path to the image from where the web page is going to be run, then you can simply bind the path into an img tag, and it will work just fine.
So lets say you have a directory named "images" which contains pic1.jpg and pic2.jpg.
you would have two records in your table with the strings
images/pic1.jpg
images/pic2.jpg
Your post does not say whether you are using classic asp or asp.net, but in asp.net, you can define an html template in a control like the DataRepeater that will get repeated once for every row in your recordset and bind the src property of the img tag inside the repeater to the data coming out of the database.
It may also be helpful to look in some web development forums for this kind of advice rather than a SQL Server discussion board. (Even though some web devs hang out here 🙂
Hope this helps
October 27, 2008 at 11:56 pm
Thanks GilaMonster, Perry Whittle and Jeremy.....!!!!
M sry but still my issue is not resolved as this is my 1st project n recently learnt ASP.NET, C# and SQL SERVER 2005.
-xp_cmdshell is not enabled and tried to put dir listing through txt file but failed to get the dir listing. i typed below words in cmd command prompt.
Error was "The system cannot find the file specified".
- You told "bind the src property of the img tag inside the repeater to the data coming out of the database." Wat should i write "Image src.........??????" i dono this sry but can u giv me more detail wat you understood is perfectly rite but i dono how shld i do code wise.
October 28, 2008 at 2:21 am
makjain (10/27/2008)
-xp_cmdshell is not enabled and tried to put dir listing through txt file but failed to get the dir listing. i typed below words in cmd command prompt.Error was "The system cannot find the file specified".
What exactly did you enter?
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
October 28, 2008 at 2:27 am
DIR dirinfo.txt
October 28, 2008 at 2:30 am
i wrote DIR opened angular brackets and wrote E:\Visual Studio Solution\Web Application\Template\Snaps and closed the brackets and wrote dirinfo.txt
October 28, 2008 at 2:35 am
When specifying generic commands, angular brackets are used as placeholders, indicating that something needs to be put in their place, not that they need to be there. See the command specifications in Books Online, or any other help file
DIR E:\Visual Studio Solution\Web Application\Template\Snaps > dirinfo.txt
The remaining bracket is the output redirector, indicating that the output, normally to console, should go to the file specified.
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
October 28, 2008 at 2:56 am
Getting same error 🙁
October 28, 2008 at 3:36 am
DIR "E:\Visual Studio Solution\Web Application\Template\Snaps" > dirinfo.txt
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
Viewing 15 posts - 1 through 15 (of 23 total)
You must be logged in to reply to this topic. Login to reply