473,394 Members | 2,002 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,394 software developers and data experts.

Uploading Docs Into Sql Server

Can someone offer or point me to some sample code or advice on how to upload a document from a web page and store it into a SQL Server image field? And then reverse the process and serve up the file from the database when requested through a web page...

Thanks.

Jerry
Oct 18 '06 #1
4 1649
Jerry,

1. Uploading is simple for the actual file uploading piece.

Use the <asp:htmlfileinput /control and when the page posts use the
..PostedFile.SaveAs(stream) method to save it. Use a SqlCommand and add
a parameter, set it's type to SqlDbType.Image.

2. Retrieving the data is relatively simple, fill your dataset and
extract the column as you would any other column. Cast it to whatever
you need...

variable = (byte[])dataset.Tables[0][x];

HTH,

-Brenton MCSD.NET

rl*****@newsgroups.nospam wrote:
Can someone offer or point me to some sample code or advice on how to upload a document from a web page and store it into a SQL Server image field? And then reverse the process and serve up the file from the database when requested through a web page...

Thanks.

Jerry
------=_NextPart_000_0006_01C6F298.D1098290
Content-Type: text/html; charset=iso-8859-1
Content-Transfer-Encoding: quoted-printable
X-Google-AttachSize: 807

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.5700.6" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT face=Arial size=2>Can someone offer or point me to some sample code
or advice on how to upload a document from a web page and store it into a SQL
Server image field?&nbsp; And then reverse the process and serve up the file
from the database when requested through a web page...</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>Thanks.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>Jerry</FONT></DIV></BODY></HTML>

------=_NextPart_000_0006_01C6F298.D1098290--
Oct 18 '06 #2
<rl*****@newsgroups.nospamwrote in message
news:O6**************@TK2MSFTNGP04.phx.gbl...
Can someone offer or point me to some sample code or advice on how to
upload a document
from a web page and store it into a SQL Server image field? And then
reverse the process and
serve up the file from the database when requested through a web page...
Google is your friend - there are loads of articles and code samples
available:
http://www.google.co.uk/search?sourc...b+binary+store
Oct 18 '06 #3
Hi Jerry,

For Uploading file in ASP.NET, there are many tech article describing this:

#How to upload a file to a Web server in ASP.NET by using Visual Basic .NET
http://support.microsoft.com/kb/323245/en-us

#ASP.NET 2.0 FileUpload Server Control
http://www.codeguru.com/dbfiles/get_....php?id=183439

Also, the following article has demonstrate store the uploaded file content
into database binary data table column:

#File Upload with ASP.NET
http://www.codeproject.com/aspnet/fileupload.asp
In addition, for reading and retrieveing binary/image data in SQL Server,
they're pure ADO.NET data accessing tasks and here are some good article
demonstrate this:
#Storing and Retrieving Images from SQL Server using Microsoft .NET
http://www.codeproject.com/cs/databa...InDataBase.asp

#Utilize ADO.NET and C# to work with BLOB data
http://builder.com.com/5100-6371_14-5766889.html
Hope this helps.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

==================================================

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.

==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

Oct 19 '06 #4
hello,
if you're using C# 2.0 then try the web control FileUpload which has SaveAs
method...
hope it'll help

"rl*****@newsgroups.nospam" wrote:
Can someone offer or point me to some sample code or advice on how to upload a document from a web page and store it into a SQL Server image field? And then reverse the process and serve up the file from the database when requested through a web page...

Thanks
Oct 19 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Kevin Ollivier | last post by:
Hi all, I've come across a problem that has me stumped, and I thought I'd send a message to the gurus to see if this makes sense to anyone else. =) Basically, I'm trying to upload a series of...
4
by: M P | last post by:
Can you help me find an asp code that will upload a file from my PC to web server? Mark
0
by: Ian | last post by:
I have created a SQL Server database in tandem with an ASP website. My ISP (Onyx) has created a SQL account for me but have given little or no instruction on how to upload my database. Initially...
7
by: Roger Withnell | last post by:
I would like to check that an image file, selected by a user using fileUpload, is within certain parameters (width, height, filesize) and to display the image file so that the user can see the...
1
by: Chris Kennedy | last post by:
I am having problems uploading web apps to our local server. Can anyone shed any light on the explanation I have been given by one of our techies. You have recreate the virtual and add server...
5
by: Chris | last post by:
I have a meetings section I'm developing on our intranet. Using PHP/MySQL. Meeting info and Meeting docs reside on 2 related tables in the db. Users may want to upload anywhere from 1 to 10 or...
1
by: jaganraj | last post by:
Hi Friends Please help me the bellow subject who knows about it well. I want upload my sql server database in my webserver. Thanks With Regards Rajeesh
6
by: snaeher | last post by:
Functions using file references to images on my local drive return the file not found warning. The functions work fine if the image has been uploaded to the server, but returns errors when calling...
1
by: onelovely | last post by:
some time images are uploaded successfully into server, now its showing error message as: Error !!Access to the path 'D:\whb\Sites\27476\Web\images\users\brace.png' is denied. what to do to upload...
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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.