473,569 Members | 2,691 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1659
Jerry,

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

Use the <asp:htmlfilein put /control and when the page posts use the
..PostedFile.Sa veAs(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*****@newsgro ups.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.D 1098290
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.D 1098290--
Oct 18 '06 #2
<rl*****@newsgr oups.nospamwrot e in message
news:O6******** ******@TK2MSFTN GP04.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*****@newsgr oups.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
7824
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 files via FTP. I'm using ftplib to do it, and for each file I'm using transfercmd("STOR " + myfile) to get the socket, then uploading 4096 bytes at...
4
2182
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
1249
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 they gave me a username and password but no server or database name. When pushed, they told me to use the domain name for the server (i.e....
7
8655
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 correct image has been chosen, before uploading it to the server. http://www.your-community.co.uk/TestImageArray.asp is an extract of the basic...
1
1231
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 extensions and make sure the underlying physical name is no longer than 8 characters?!!!? I smacks of some kind of hare-brained workaround. Does anyone...
5
2711
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 more documents to share/use during a meeting presentation. What would be the most efficient way to approach this? This is the logic I'm currently...
1
1350
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
2706
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 information for an image residing on the local drive. I'm attempting to reduce the upload time for large pictures. Any thoughts? :) EXAMPLE ...
1
1211
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 images i am using c-sharp code. Thanks
0
7698
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
8122
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7673
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7970
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6284
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5513
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3640
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1213
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
937
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.