Showing posts with label retrieve. Show all posts
Showing posts with label retrieve. Show all posts

Wednesday, March 7, 2012

How to store/retrieve image/file in sql db

Hi Guys,
I want to employee details in one table along with his photograph and resume
.
How can I achieve this? I'm fresher and I don't have any basic idea about th
is.
Can somebody lead me to a worked out example.
If appropriate how to use WRITETEXT/READTEXT to achieve this task?
thanks in advance.
M.L.SrinivasYou can start here:
http://support.microsoft.com/kb/308042
or
You can use TextCopy.exe in the \bin folder.
-- OJ: TEXTCOPY example
-- Loading files into db &
-- exporting files out to folder
--
--TEXTCOPY IN
--
--create tb to hold data
create table tmp(fname varchar(100),img image default '0x0')
go
declare @.sql varchar(255),
@.fname varchar(100),
@.path varchar(50),
@.user sysname,
@.pass sysname
set @.user='myuser'
set @.pass='mypass'
--specify desired folder
set @.path='c:\winnt'
set @.sql='dir ' + @.path + '*.bmp /c /b'
--insert filenames into tb
insert tmp(fname)
exec master..xp_cmdshell @.sql
--loop through and insert file contents into tb
declare cc cursor
for select fname from tmp
open cc
fetch next from cc into @.fname
while @.@.fetch_status=0
begin
set @.sql='textcopy /s"'+@.@.servername+'" /u"'+@.user+'" /p"'+@.pass+'"
/d"'+db_name()+'" /t"tmp" /c"img" /w"where fname=''' + @.fname + '''"'
set @.sql=@.sql + ' /f"' + @.path + @.fname + '" /i' + ' /z'
print @.sql
exec master..xp_cmdshell @.sql ,no_output
fetch next from cc into @.fname
end
close cc
deallocate cc
go
select * from tmp
go
--
--TEXTCOPY OUT
--
declare @.sql varchar(255),
@.fname varchar(100),
@.path varchar(50),
@.user sysname,
@.pass sysname
set @.user='myuser'
set @.pass='mypass,'
--specify desired output folder
set @.path='c:\tmp'
set @.sql='md ' + @.path
--create output folder
exec master..xp_cmdshell @.sql
--loop through and insert file contents into tb
declare cc cursor
for select fname from tmp
open cc
fetch next from cc into @.fname
while @.@.fetch_status=0
begin
set @.sql='textcopy /s"'+@.@.servername+'" /u"'+@.user+'" /p"'+@.pass+'"
/d"'+db_name()+'" /t"tmp" /c"img" /w"where fname=''' + @.fname + '''"'
set @.sql=@.sql + ' /f"' + @.path + @.fname + '" /o' + ' /z'
print @.sql
exec master..xp_cmdshell @.sql ,no_output
fetch next from cc into @.fname
end
close cc
deallocate cc
set @.sql='dir ' + @.path + '*.bmp /c /b'
exec master..xp_cmdshell @.sql
go
drop table tmp
go
-oj
"M.L.Srinivas" <mlsrinivas@.indiatimes.com> wrote in message
news:9fa72100.0502102147.1a18787@.posting.google.com...
> Hi Guys,
> I want to employee details in one table along with his photograph and
> resume.
> How can I achieve this? I'm fresher and I don't have any basic idea about
> this.
> Can somebody lead me to a worked out example.
> If appropriate how to use WRITETEXT/READTEXT to achieve this task?
> thanks in advance.
> M.L.Srinivas|||I have gone threw this tutorial. But when I retrieve the image from the DB.
The image is only 1B, and I cannot open it. The filename is correct.
Whats wrong here?
-- Kenneth
"oj" wrote:

> You can start here:
> http://support.microsoft.com/kb/308042
> or
> You can use TextCopy.exe in the \bin folder.
> -- OJ: TEXTCOPY example
> -- Loading files into db &
> -- exporting files out to folder
> --
> --
> --TEXTCOPY IN
> --
> --create tb to hold data
> create table tmp(fname varchar(100),img image default '0x0')
> go
> declare @.sql varchar(255),
> @.fname varchar(100),
> @.path varchar(50),
> @.user sysname,
> @.pass sysname
> set @.user='myuser'
> set @.pass='mypass'
> --specify desired folder
> set @.path='c:\winnt'
> set @.sql='dir ' + @.path + '*.bmp /c /b'
> --insert filenames into tb
> insert tmp(fname)
> exec master..xp_cmdshell @.sql
> --loop through and insert file contents into tb
> declare cc cursor
> for select fname from tmp
> open cc
> fetch next from cc into @.fname
> while @.@.fetch_status=0
> begin
> set @.sql='textcopy /s"'+@.@.servername+'" /u"'+@.user+'" /p"'+@.pass+'"
> /d"'+db_name()+'" /t"tmp" /c"img" /w"where fname=''' + @.fname + '''"'
> set @.sql=@.sql + ' /f"' + @.path + @.fname + '" /i' + ' /z'
> print @.sql
> exec master..xp_cmdshell @.sql ,no_output
> fetch next from cc into @.fname
> end
> close cc
> deallocate cc
> go
> select * from tmp
> go
> --
> --TEXTCOPY OUT
> --
> declare @.sql varchar(255),
> @.fname varchar(100),
> @.path varchar(50),
> @.user sysname,
> @.pass sysname
> set @.user='myuser'
> set @.pass='mypass,'
> --specify desired output folder
> set @.path='c:\tmp'
> set @.sql='md ' + @.path
> --create output folder
> exec master..xp_cmdshell @.sql
> --loop through and insert file contents into tb
> declare cc cursor
> for select fname from tmp
> open cc
> fetch next from cc into @.fname
> while @.@.fetch_status=0
> begin
> set @.sql='textcopy /s"'+@.@.servername+'" /u"'+@.user+'" /p"'+@.pass+'"
> /d"'+db_name()+'" /t"tmp" /c"img" /w"where fname=''' + @.fname + '''"'
> set @.sql=@.sql + ' /f"' + @.path + @.fname + '" /o' + ' /z'
> print @.sql
> exec master..xp_cmdshell @.sql ,no_output
> fetch next from cc into @.fname
> end
> close cc
> deallocate cc
> set @.sql='dir ' + @.path + '*.bmp /c /b'
> exec master..xp_cmdshell @.sql
> go
> drop table tmp
> go
>
> --
> -oj
>
> "M.L.Srinivas" <mlsrinivas@.indiatimes.com> wrote in message
> news:9fa72100.0502102147.1a18787@.posting.google.com...
>
>

How to store PDFs and photos in the database?

Is it easy to store and retrieve photos and PDFs in SQL Server 2000?
My boss thinks it should be drag and drop but I can't find anything on it. Is there any programming involved or is it transparent to the user? We would like to store PDFs and JPGs in SQL then link to them with JSP (we don't do asp) displaying the resu
lt in a web browser.
Are there any white papers on the subject?
Thanks,
Randy K
wawork@.hotmail.com
SQL Server is not Access, and nothing is drag 'n' drop. You will have to do
some programming if you want to do it.
Here is some general info on whether it's a good idea to store images in a
SQL Server database at all:
http://www.aspfaq.com/show.asp?id=2149
As for how to do it, that depends on your client... Search the archives of
this group as well as Google and you'll find lots of examples in different
languages.
"Randy K" <anonymous@.discussions.microsoft.com> wrote in message
news:CBEB9065-12D3-4488-9D11-E01D89B55C2B@.microsoft.com...
> Is it easy to store and retrieve photos and PDFs in SQL Server 2000?
> My boss thinks it should be drag and drop but I can't find anything on it.
Is there any programming involved or is it transparent to the user? We
would like to store PDFs and JPGs in SQL then link to them with JSP (we
don't do asp) displaying the result in a web browser.
> Are there any white papers on the subject?
> Thanks,
> Randy K
> wawork@.hotmail.com
>
|||This posting is provided "AS IS" with no warranties, and confers no rights
Hi ,
I found the following link which talks abt something similar , however it
uses oracle as a backend :
2 Program Examples Using Multimedia JSP Tags:
http://otn.oracle.com/products/inter...l/jsptaglib_ex
amp.htm
hope it helps.
Regards,
Venkat.
|||This posting is provided "AS IS" with no warranties, and confers no rights
Hi ,
I also found the following link which talks abt the same . It s forum
which discuss the same topic . Hope it helps ..!!
Topic: how to display images in jsp :
http://forum.java.sun.com/thread.jsp...essage=2467239
Regards,
Venkat.

How to store PDFs and photos in the database?

Is it easy to store and retrieve photos and PDFs in SQL Server 2000?
My boss thinks it should be drag and drop but I can't find anything on it.
Is there any programming involved or is it transparent to the user? We wo
uld like to store PDFs and JPGs in SQL then link to them with JSP (we don't
do asp) displaying the resu
lt in a web browser.
Are there any white papers on the subject?
Thanks,
Randy K
wawork@.hotmail.comSQL Server is not Access, and nothing is drag 'n' drop. You will have to do
some programming if you want to do it.
Here is some general info on whether it's a good idea to store images in a
SQL Server database at all:
http://www.aspfaq.com/show.asp?id=2149
As for how to do it, that depends on your client... Search the archives of
this group as well as Google and you'll find lots of examples in different
languages.
"Randy K" <anonymous@.discussions.microsoft.com> wrote in message
news:CBEB9065-12D3-4488-9D11-E01D89B55C2B@.microsoft.com...
> Is it easy to store and retrieve photos and PDFs in SQL Server 2000?
> My boss thinks it should be drag and drop but I can't find anything on it.
Is there any programming involved or is it transparent to the user? We
would like to store PDFs and JPGs in SQL then link to them with JSP (we
don't do asp) displaying the result in a web browser.
> Are there any white papers on the subject?
> Thanks,
> Randy K
> wawork@.hotmail.com
>|||This posting is provided "AS IS" with no warranties, and confers no rights
Hi ,
I found the following link which talks abt something similar , however it
uses oracle as a backend :
2 Program Examples Using Multimedia JSP Tags:
http://otn.oracle.com/products/inte...ml/jsptaglib_ex
amp.htm
hope it helps.
Regards,
Venkat.|||This posting is provided "AS IS" with no warranties, and confers no rights
Hi ,
I also found the following link which talks abt the same . It s forum
which discuss the same topic . Hope it helps ..!!
Topic: how to display images in jsp :
http://forum.java.sun.com/thread.js...message=2467239
Regards,
Venkat.

how to store Linefeeds to a database and retrieve them

hello all,

I have a multi line textbox and want to store the content of the textbox to a database. I want to preserve the linefeeds so that I display the message as it is typed by retrieving it. Can anyone please explain how to store the linefeeds to the database. Once i store the linefeeds to the database, I can restore them using the Replace("\n","<br/>) method. But I can't figure out how to store the \n 's in the database in the first place.

Thanx in advance

look into Environment.NewLine.

|||

The Environment.Newline is for VB.net

But in C#, \n is automatically stored in the database and I jus need to replace it with <br /> using replace method.

Thanx for the reply

How To Store Images in a database table

Hello All,

My question is how to store images in a database table (in SQL Server), and how to retrieve them?...

Thanks,

Hi,

please take a look at this article:Storing Binary Files Directly in the Database Using ASP.NET 2.0.

Grz, Kris.

|||Thanks, I read the article...

Friday, February 24, 2012

How to store GPS Coordinates in database, Which Data Type?

I am working on a program in VB 2005 in which i want to store and retrieve GPS coordinates. I am not sure which data type is the best to use to enter Latitude & Longitude numbers and maintain their proper integrity.

Like LAT ( N38 28.025' ) and LONG (W105 52.098' )

The numbers will be entered by the user and that format can be maintained, but how to re-enter & or insert them into the database using the same format is my real question.

I hope I have explained this right. The numbers in BOLD are what I need to maintain.

Thanks for any help in advance.

Steve

Hi Steve,

are you using SQL Server 2005 ? YOu could create your own data type for that ! I am not quite sure if since now anybody did already one for that reason but it would be worth a try searching in google for CLR +data type +sql server 2005 (and then the appropiate buzz words you probably know for your problem, like special names for the coordinates etc.

HTH, Jens K. Suessmeyer.

http://www.sqlserver2005.de

|||

You could look at a SQL CLR User defined data type.The other option is to store as integers (or numerics) and then have a function that converts from the raw numeric value to the format above.

With a UDT you implement a parse method that allows you to interpret text into a value that you can store.

Be careful with UDTs though as changing them once in place is very difficult, as it is in use and so you can't just upgrade the base assembly.

how to store and retrieve image files in sql server

hi like to knw the steps for storing 1000+ image files in an sql server.....
i/p: 1000+ image files

o/p: should be displayed in an vb6 environment in an pic box.....I would recommend you storing full path to picture file and not file itself then get path from a database and load picture from file into a picture box.
It is extremely slow and complicated to do it on the database side. You should be able to convert picture file into a binary stream to store it on the database and then be able to decode this binary stream back to picture.

Good Luck.