Downloading files from SQL Server 2000

Hi,

I have managed to upload files to the DB via asp.net pages - now I'm busy with the download part.
Most articles suggest using a datareader to read the blob field and then outputting the result directly to the output stream via something like response.binarywrite().
The FIRST problem, however is that respone.contenttype() has to be set for the applicable MIME type - this means that you either have to set this property when you upload the file (as another field in the DB) or you have to only upload one file type....
Q1: Is there a way to dynamically determine the file's MIME type?
I guess you could look at the file extension and compare to a list of types - perhaps this is the only way.
The SECOND problem is that once you have selected the file to download and proceed to the aspx page that streams the file, you will be prompted to save the file, but the default filename will be the aspx filename.... This means the user has to save the file with another name and the correct extension.
Q2: Is there a way to set the default file name for the stream?
Help would be much appreciated. Thanks
James
0
micklemj
8/29/2002 1:24:43 PM
asp.net.sql-datasource 29906 articles. 0 followers. Follow

5 Replies
619 Views

Similar Articles

[PageSpeed] 1

Sorry, this seems to be becoming a habit.  Five minutes after posting this message I solved both problems.

For anyone with similar problems, this is what I did:
For the conttentype I used "application/octet-stream" which seems to work for most files.
For the default filename, I used:
Response.AddHeader("Content-Disposition","attachment; filename=" & myDataReader.Item("FileName") & ";")
And so ends an arduous, frustrating journey.
Uploading files to and downloading files from SQL Server is very useful (directory security, etc.) and if anyone else is having problems with this, I will happily post my entire method.
James
0
micklemj
8/29/2002 1:41:50 PM
Can you post your entire code?  Everything works for me except I keep getting a 50 byte file.

thx,
Keith
0
Spdracer
1/11/2003 12:06:24 AM
Okay, dumb me found the problem!  Make sure not to use Binary as the column type.  It was set to 50.  I ended up just using image as the column type.  I'm sure varBinary would work as well but I haven't tried it out yet.
0
spdracer
1/14/2003 2:01:54 AM
Hi Micklemi,

Can you be able to post your entire method of how downloading files from SQL server 2000?
In my portal, I have saved the MS word in the table as image type, and would like to automatically download to user client PC once they have clicked the <check out> button and update the check-out status into check-in status.
Can you kindly provide me your solution.
Michael
0
mwoong
3/14/2004 11:48:51 PM

Will you post the complete solution please.

pcg

0
pcg
7/25/2008 5:55:47 AM
Reply:

Similar Artilces:

SQL Server Reporting Services for SQL SERVER 2000 AND Visual Studio.NET 2005 .NET 2.0
Hi, Which version of SQl Server Reporting Services will work with SQL SERVER 2000 in pararrel with ASP.NET 2.0 (.NET 2.0 framework)?  Thanks, Azam HighOnCodingWanna get high! Hi, Okay I got the answer. Yes, we can use the SQL SERVER 2005 Reporting Services with SQL SERVER 2000. HighOnCodingWanna get high! ...

SQL Server 2005 Installation problems with SQL Server Express & SQL Server 2000
Hi Guys, I have had SQL Server Express and Sql Server Management Studio Express installed on my machine for some time and recently tried to install a trial of SQL Server 2005 as well.  (Yes, I'm migrating from Visual Studio Express to Visual Studio Professional, just as in tended!) Everything went fine except that nothing seemed to be installed.  I searched in all the obvious places - both on the Start/Programs menu and on the hard-drive: nothing. A check under Add/Remove Programs showed that Sql Server 2005 Express was installed, but called SQL Server 2005. So after a number o...

This version of Microsoft Sql Server Management Studio can only be used to connect to Sql Server 2000 and Sql Server 2005 servers
When I connect SQL Server 2005 to a remote database i get the error: "This version of Microsoft Sql Server Management Studio can only be used to connect to Sql Server 2000 and Sql Server 2005 servers". Can I confirm it is because: the remote db is of SQL Server 2008? There is a soln mentioned in http://forums.asp.net/t/1324047.aspx Did anybody try this (installing 2008 express: http://www.microsoft.com/express/sql/download/)? I am just checking again, whether it will disturb my existing SQL Server installation, in any means...? Though it is mentioned that it will g...

SQL Server 2000 and SQL Server 2005 in the same server
Can enyone please send me a link to a white paper explaining how to run both SQL Server 2000 and 2005 in the same machine?Thanks. I don't know about the white paper but I had both running on my machine for a while by making the SQL 2000 a named instance. So for SQL 2005 connection strings my server name was (local) while for SQL 200 using the named instance it was (local)\joesql where joesql was the instance nameHope it helps,Joe http://www.joeaudette.comhttp://www.mojoportal.com...

Creating a SQL Server 2000 compatible .BAK file from SQL Server Management Studio Express
Hi,My webhost (1and1) is running SQL Server 2000 and their web tool supports the import of .bak files. However, when I try to import my .bak files created in SQL Server Management Studio Express I get the following error:"The backed-up database has on-disk structure version 611. The server supports version 539 and cannot restore or upgrade this database. RESTORE FILELIST is terminating abnormally."I have  Googled this error and learnt that 2005 .bak files are not compatible with 2000 .bak files. I'm just wondering if there are any work arounds to this or alternative tool...

SQL Server 2000 Developer vs SQL Server 2000 Standard
I have installed the SQL Server 2000 developer that came with Office XP Developer. I now have a copy of SQL Server 2000 Standard. What will happen if I try to install the standard version? Will I loss any of my current database logins or settings, etc...? Thank you for any help,Thank youJackxxx Upgrading your version of SQL Server 2000 should not result in the loss of any information that you already have set up. I believe you can/should choose "Upgrade, remove, or add components to an existing instance of SQL Server" when you go to install SQL Server 2000 Standard. TerriT...

SQL SERVER 2000: In which format the datetime will be stored in sql server 2000?
Hi All, I would like to know, how the datetime will be stored in the sqlserver datetime column. Because some time i am giving the date in dd/mm/yyyy and sometime mm/dd/yyyy. while give the date in mm/dd/yyyy works fine but not in the another case. and also while i execute a query on query analyser it shows the datetime in yyyy/mm/dd format. So anyone can please tell me how the dates will be stored in the datetime column of sqlserver database? Thanks in Advance. Regards, Dhanasekaran. G Storing of datetime depends upon the globalization setting. Normally the date time is stor...

Bulk Copy between remote SQL Server 2000 and local SQL Server 2000
How to perform Bulk Copy of a table from a Remote SQL Server 2000 to Local SQL Server 2000?I need to do this programmatically. This will be performed on regular basis. I can't use DTS Import/Export Wizard. Need the steps of Bulk Insertion.Thanks in advance. With Regards,Prodipta Mondal.Please remember to click “Mark as Answer” on the post that helps you. This can be beneficial to other community members reading the thread. Need the steps of Bulk Insertion.  Connect to the remote SQL Server. Load a DataTable or DataReader Connect to the local Server Call the SQLBulkCopy,WriteTo...

sql server 2005 to sql server 2000
Due to certain unavoidable reasons we have to move an application from sql server 2005 to sql server 2000 (yes from 2005 to 2000).  would changing the connection string be sufficient or are there other issues involved. How hard is it going to be to get it to work? Any tips or suggestions are greatly appreciated. Yes you will need to change the connection string!However you must look very carefully at the database structure. Do two script exports of every object in the database - one for SQL2000 compatibility and one without. Compare these two scripts, if they are significantly differe...

SQL Server Express file to Sql Server
I would like to copy the schema and data of a sql server express database file to a SQL Server Database. How can this be done and what steps would I need to take?   Thanks for any helpTinyPond TinyPond:I would like to copy the schema and data of a sql server express database file to a SQL Server Database. How can this be done and what steps would I need to take? If you have Express Management Studio, you back backup your database, and them import it to SQL Server (or attach and reattach).Justs open SQL Server Express Management Studio, connect to your Express instanc...

Converting MDF files (SQL Server Express) to SQL Server 2005 WITHOUT having to buy SQL Server 2005 (I have Express). Personal WebSite Starter Kit
Hi (and HELP!),   I downloaded the Personal WebSite Starter Kit and got it working no problem on my local machine.  But I've had nothing but frustration trying to get it up and running on a webhosting site.  I picked hostmysite.com which uses SQL Server 2005.  I was under the impression that it wouldn't be that big a deal to convert the .MDF files that Sql Server Express uses to a SQL Server 2005 database.  I tried using SQL Server Management Studio Express.  I was able to "see" my remote database on hostmysite.com, but I was not able to import the .mdf file...

Converting MDF files (SQL Server Express) to SQL Server 2005 WITHOUT having to buy SQL Server 2005 (I have Express). Personal WebSite Starter Kit
Hi,Basically i built a webpage with Login and it's working well from my local machine.Right now, i'm using Database Publishing Wizard. the problem is how do i convert.MDF files to .SQL 2005 to get my database publish in the internet? thanks  Place your .MDF file in the App_Data directory, change the connection string accordingly and then publish your web site. ----------------------------------------------------------Please click Mark As Answer if this helped in solving your problem.  Please click "Mark As Answer" if this hepled in solving your problem. ...

Converting MDF files (SQL Server Express) to SQL Server 2005 WITHOUT having to buy SQL Server 2005 (I have Express). Personal WebSite Starter Kit
Hi (and HELP!),   I downloaded the Personal WebSite Starter Kit and got it working no problem on my local machine.  But I've had nothing but frustration trying to get it up and running on a webhosting site.  I picked hostmysite.com which uses SQL Server 2005.  I was under the impression that it wouldn't be that big a deal to convert the .MDF files that Sql Server Express uses to a SQL Server 2005 database.  I tried using SQL Server Management Studio Express.  I was able to "see" my remote database on hostmysite.com, but I was not able to import the .mdf files ...

Sql Server Script File(.sql) Execution by Vb.net Code
I have a problem. I m working on "light weight sql server"  project.   and i want to execute .sql file through vb.net code with the help of sqldmo library and sqlns namespace. but i donot know any method to directly execute the .sql file. i am successfully making the full script of select database of sql server.   please help me.... thanks.... Hi, You can use SQL-DMO object in your .net projects by referencing Sqldmo.dll  file which is in  C:\Program Files\Microsoft SQL Server\80\Tools\Binn  folder is default installation parameters are used. I...

Web resources about - Downloading files from SQL Server 2000 - asp.net.sql-datasource

Uploading and downloading - Wikipedia, the free encyclopedia
... include a web server , FTP server, email server, or other similar systems. A download can mean either any file that is offered for downloading ...

Dropify Download 2.0 Simplifies Uploading Content To Facebook, Downloading, Sharing
... with Facebook’s Open Graph and allowing users to make files available for download via the social network, and share uploading and downloading ...

I'm Downloading on the App Store on iTunes
Get I'm Downloading on the App Store. See screenshots and ratings, and read customer reviews.

Why is Dropbox so slow at downloading?
I've upgraded to the new version, and have relinked the machine that was upgraded. It's downloading at 5K per second. Why so slow? This is on ...

XBMCTorrent Plugin for Downloading or Streaming to XBMC from Torrent Sites ( i.e. PirateBay) - YouTube ...
YouTube: http://YouTube.com/user/xbmchelper XBMCast: http://xbmchelper.squarespace.com Official: http://xbmchelper.webs.com Website: http:// ...

Has downloading killed the video star?
It's a ritual as old as VHS.

You Might Not Get Fined For Downloading Dallas Buyers Club
Dallas Buyers Club pirates and torrenters, there may be a shining light at the end of the dark tunnel ahead of you. The studio behind the movie ...

Downloading movies and TV is not a crime
You wouldn't steal a car... but a movie or television show? Most of us seem fine with that.

Music Piracy - Illegal Downloading - Kazaa - Woman Loses Appeal
US woman loses $222,000 music downloading appeal

An epidemic in illegal downloading
Missing one episode of West Wing, thanks to constant schedule changes, was enough to set Mark and Kim down the road to online piracy.

Resources last updated: 11/25/2015 1:25:00 AM