473,396 Members | 1,797 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

How to save files in database....

37
Hi All,

How can i save any extension file type in the database and retreive that file when i want.

what i mean here that i have different file types like .txt,.doc,pdf etc.

how to save these file in database and retreive when needed and show it to user on request.

Is it possible ? can u please give me some sample code.



Thanks

-yanku
Oct 27 '08 #1
3 1210
Curtis Rutland
3,256 Expert 2GB
The column-type you will store it in depends on the database you are working on. MSSQL uses "Image", MySql uses "BLOB", Access uses "OLE Object".

But the basic idea is to use a FileStream to fill a Byte array (byte[]) and then use that byte array as a parameter for your insert query.
Oct 27 '08 #2
john20
37
Hi thanks for your reply.

Can u please provide some code about how to convert file into bytes stream
Oct 27 '08 #3
Curtis Rutland
3,256 Expert 2GB
No, because we're trying to help you help yourself.

However, I can give you a link to the MDSN Page for the FileStream object, and I can point you in the right direction:

Here's how to create a filestream object:
c#
Expand|Select|Wrap|Line Numbers
  1. using System.IO;
  2. .
  3. .
  4. .
  5. FileStream fs = new FileStream(@"c:\path\file.txt",FileMode.Open, FileAccess.Read);
  6.  
Change the path, FileMode, and FileAccess values as necessary, although for this task, this should be fine.

The method you will need to use to read the file's data is called "Read".
Oct 27 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Jake | last post by:
Hi group, I am trying to build a page that allows uploading My ISP only supports Smartupload I am testing on a small hubbed local network, with PWS Any help is appreciated....
2
by: Jon | last post by:
I have a sql table that hold binary files as blobs. Our customers store attachments for their work orders in them, anything from xml files to zip files. Normally, these files first exist on the...
4
by: kev | last post by:
Hi folks, I have created a database to store information on equipments. During the first level of registration, there is a form that i need the user to fill up details on the equipment testing....
8
by: paquer | last post by:
I'd like to provide an Export Function from my forms, where the User can choose the File name & save location Although I cannot get the "Save As" dialog box to open properly from access. What is...
5
by: countnazgul | last post by:
Hello, I've got very odd problem. I use windows application to store files in data base (MySql) and then to extract this files from data base and save it on hdd. But when i save them back to hdd...
3
by: =?Utf-8?B?YzY3NjIyOA==?= | last post by:
Hi all, I have a question for you. I have a .csv file which has many lines of data. Each line has many data fields which are delimited by ",". Now I need to extract part of data from this...
2
by: JPS | last post by:
We have a ASP.Net/SQL Server application that is used as a document management system. The documents are stored per project. The files are stored on a file server but we store the file name in the...
0
by: Edwin.Madari | last post by:
since choice of dbm used by shelve http://docs.python.org/lib/node327.html depends on os, and whats available on it, shevle files saved on one os, most likely do not work on another os, sometimes on...
3
by: evenlater | last post by:
I have an Access application on a terminal server. Sometimes my users need to export reports to pdf, rtf or xls files and save them to their own client device hard drives. They can do that right...
11
by: fniles | last post by:
One of our application uses VB6 and Access97 database. Another application uses VB.NET 2005. This morning for about 15 seconds when the application tries to read either a query or a table from the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.