Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
SQL Server 2000 General discussion of Microsoft SQL Server -- for topics that don't fit in one of the more specific SQL Server forums. version 2000 only. There's a new forum for SQL Server 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server 2000 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old February 27th, 2006, 08:02 AM
Authorized User
Join Date: Jan 2006
Location: , , .
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Default how to store a text file

Dear Members,
I want to know how to insert text file in sql server database using jsp,servlets and jdbc technology.
       i have tried lots of times but failed.i mean what kind of field should i take in database to store the file. how can i insert it ito that and how can i retrieve it from there.


regards ,Vivek
  #2 (permalink)  
Old July 4th, 2006, 08:22 AM
Registered User
Join Date: Jul 2006
Location: chandigarh, chandigarh, India.
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts

You can take text field as datatype in sql server,You can reterive it like any other field using select query and assign it to any control like label we have in asp.net

  #3 (permalink)  
Old July 4th, 2006, 09:18 AM
Authorized User
Join Date: Mar 2006
Location: , , .
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts

Hi Vivek!

I think you want to store the whole file into database, not the textual entries. As Praveen has posted, his approach is good, if you want to store textual entries into database that will do. But, if you want to store whole file into database, you can follow these steps -

Initial Steps :
[1] Create a table in your database. For example -
create table tbl_01 ( id int , txt_file text)
[2] Insert a value into it -
insert into table01 values(1,' ' )

[3] Type the following command in command. (Change Server, Database name)

(1) Insert into database -
In command line, Type the following (in a single line)
(Textcopy.exe located in mssql\binn directory)
TEXTCOPY.exe -Ssrv_name -Usa -Ppassword -Ddb_name -T tbl_01 -C txt_file -F"x:\any_file.txt" -W"where id=1" -I
Switches :
-S : server name
-U : user name
-D : database name
-T : table name
-C : column of the table
-F : file name
-W : a where query that specifies row.

(2) Out the file from database -
TEXTCOPY.exe -Ssrv_name -Usa -Ppassword -D DB_NAME -T tbl_01 -C txt_file -F"x:\any_file.txt" -W"where id=1" -O

In this example -
srv_name : Name of Server
DB_NAME : Name of your Database
Tbl_01 : Name of Table (Created in this demo)
txt_file : Name of column with Text data-type.
x:\any_file.txt : Full path of file to be copied.

Rarely we need to copy the whole file into database. Because, it was asked, i am replying you. I think this help is at basic level and you must have got it well.

But, this help is bound to SQL Server only. How these things can be done through JSP, I don't have any idea.

If you can call any application like we do in Visual Basic through - Shell(<Application Name>); you can try out the same with Java.

Reply soon ..
(As a custom, if you don't reply, I don't bother..lol)

- Som Dutt

Similar Threads
Thread Thread Starter Forum Replies Last Post
store a single line of text from a file....how???? danielnixon General .NET 2 May 1st, 2008 12:09 PM
how to store text file in database vivekkumar_23 Servlets 1 February 13th, 2006 05:29 AM
How to store ntext or text value to local variable ramk_1978 SQL Server 2000 3 September 14th, 2005 07:59 PM
How to store a file name in a field ? SKE Access ASP 6 May 14th, 2005 04:46 AM
asp & text files as data store? raa BOOK: Beginning ASP 3.0 1 November 20th, 2003 06:17 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.