.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Upload file to server or database

Posted By:      Posted Date: September 15, 2010    Points: 0   Category :ASP.Net
hi,I'd like to know how to allow user to upload file to the server in mvc 2 application. I haven't seen a very clear tutorial for this, at least not on this website. There is a movie database tutorial but that is simply a list of movies not actual files. What is the simplest method for uploading files, be they images or movies? Thank you for your time.

View Complete Post

More Related Resource Links

Insert Excel Data via File Upload into sql server database???

Hi all, I have requirement that User can Upload the Excel Sheet Data to sql server Database at once. How i do that Any Article or hint is apperciated.   Regards 

How to upload a file to web server in asp.net and store file path into database table?

This article describe how to upload a file into web server folder using asp.net file upload control and store the file information into sql server database.

Can't restore database backup file in my database ? using sql server 2005. please help

VERY IMPORTANT i am trying to restore database.bak in sql server 2005 (i know the database.bak was also generated in sql 2005 server) i am trying to restore back up database .bak into the new database i just created in sql server 2005 i have saved my database .bak into c drive and when i select database .bak "From Device", it doesn't get populated in the list below and i see nothing and it keeps on prompting a message "You must select a restore source" Here's the screen shot:   PLEASE HELP..it's really important (i tried restoring database in sql server 2008 and it was sucessful but i am facing this problem in sql server 2005 only)  

File Upload Server Control

I have a FileUpload Control on a Content page of a Master Page. I need to upload an image and display it before user can upload it. Can someone advice (with example if possible)  what FileUpload event will notify me that a file was selected so I can than display it? Is this the best way to perfom this task? Can anyone advice of a better way?

Shrink database log file sql server 2005

Hi, I am trying to shrink log file for a testing database.This database will be restored with production database periodically.When i tried to create backup of the log file Processed 0 pages for database 'hcbeta', file 'HC_log' on file 6. The log was not truncated because records at the beginning of the log are pending replication. Ensure the Log Reader Agent is running or use sp_repldone to mark transactions as distributed. BACKUP LOG successfully processed 0 pages in 0.423 seconds (0.000 MB/sec). I tried EXEC sp_repldone @xactid = NULL, @xact_segno = NULL, @numtrans = 0, @time = 0, @reset = 1 Resulted with error:Unable to execute procedure. The database is not published. Execute the procedure in a database that is published for replication. So tried to publish the database using EXEC sp_dboption 'hcbeta', 'Publish', 'true' resulted error mesage:Msg 15242, Level 16, State 1, Procedure sp_dboption, Line 138 Database option 'Publish' is not unique. and retrived duplicate_options as "merge Publish" ,"Publish" Plesae help me in shrinking my database log file. Thanks, Adi.

Upload image to database - couldn't find file path

I'm trying to display images in a GridView (yes, still this...). [edit] Before I can come to that I have to upload some images to the database.I've followed this tutorial for the "upload image to database" code (this worked fine for uploading images, but I don't know if the images were converted to byte):http://aspsnippets.com/Articles/Save-Files-to-SQL-Server-Database-using-FileUpload-Control.aspxand I've followed this tutorial for the "display images in gridview" code (and "retrieve file" from the tutorial below).http://www.aspsnippets.com/Articles/Display-images-from-SQL-Server-Database-in-ASP.Net-GridView-control.aspxIt doesn't quite work, the GridView shows but without imagesNow I'm trying to change the "save file" code according to this tutorial:http://aspsnippets.com/Articles/Save-and-Retrieve-Files-from-SQL-Server-Database-using-ASP.Net.aspxbut I don't understand everything in it. When I try to upload an image I get an error on this line:FileStream fs = new FileStream(filePath, FileMode.Open, FileAccess.Read); //couldn't find file (path to image I tried to upload) What should I do about it?

buffer data from a sql server database file

I'm in need of a sample code that will let me buffer data from a database so that I can go next> and <prev in a database file. Does someone have an idea on now to do this. Joe      Toppers BBS http://toppersbbs.dtdns.net C# Windows and Console applications. PHP, Mysql. HTML

Problem trying to attach database file to Microsoft SQL Server Management Studio

I was trying to attach a database to SQL Server MGT Studio and got an exception error.  The message stated that the database file I was trying to attach could not be opened because it was version 661.  The SQL Server shows to support version 655 and earlier.  It states that a downgrade path is not supported. Question:  Is there some download ; fix; I can make to SQL Server 2008 that will allow me to attach the version 661????  I am not technical at all.  Please speak slowly.  :)  Thanks

File Upload to database (and download)



How can I upload a file to a database (with as little code as possible!) along with a desciption of a file and then search through the descriptions to retrieve the appropriate files. Then how can I click on one and download it.

I am not a very advanced programmer and would like full step by step code if possible not just a link to a website.

Thank you very much


Save file into the Sql Server database



I want to upload a file (e.g. .xls, .pdf, .doc) and save into the Sql Server 2000 database through the web interface, and then to download this file. Any idea???

Can i upload file to database table using AsyncFileUpload ?



can i upload my pdf or word file to oracle/SqlServer database table ?

How ? 

Cannot attach a database file to SQL server 2008 Express


When I try to attach a database using SQL server 2008 express version, it gives me an error message.  it says

"Msg 18456, Level 14, State 1, Server LINDA\SQLEXPRESS, Line 1
Login failed for user 'LINDA\Linda'"

How can I fix this error?


Cannot create database diagrams for sqlexpress .mdf file in Visual studio server explorer



I've look around the forums but I can't get the solution for my problem. I've installed Visual studio 2010 with sqlexpress edition. Then I have renamed my computer. After renaming my computer I've deleted the directory C:\Users\uporabnik\AppData\Local\Microsoft\Microsoft SQL Server Data\SQLEXPRESS. After restart, I have started VS2010, open Server explorer and I've added the connection to a new database. I've been able to add new tabels, bu when I've tried to add a diagram, it didn't work. In properties window od the database I saw, the the database owner was oldComputerName\username not newComputerName\userName. In sql server management studio I've reanmed the user oldComputerName\userName to newComputerName\userName. After attaching the database it worked fine.

I've returned to Visual studio 2010. When creating new database, the owner of new database is oldComputerName\userName. The next tip was renaming the  SQLServerMSSQLUser$ComputerName$SQLEXPRESS(and other names with sql...) in Local Users and gorups in Mange My computer. After restarting the compter I've got the same result. When creating new .mdf file in server explorer of visual studio, the database owner is oldComputerName\userName.<

Importing large dat file into sql server database

I have a dat file which consists of thousands of columns which i have to insert into a database. I have to insert the data into multiple datatables. I am looking for the best possible way to do that. I have looked into bulk insert also but is there a better way? something like normalizing the data in the data access layer and inserting into the tables or creating ssis packages? Any help is highly appreciated.

Server Error while file upload in asp.net mvc2


When i upload a file of size 35MB or more it gives

Server Error
404 - File or directory not found.
The resource you are looking for might have been removed, had its name changed, or is temporarily unavailable.

and if i upload a file of size 25MB or less then that it works fine. This issue occurred only when i deploy it on a server if i run it on my local system it works perfectly. One thing i want to tell that i have override httpruntime setting in my web.config and its have

<httpRuntime maxRequestLength="3145728" executionTimeout="1200" requestValidationMode="2.0"/>

what may be the issue?

server side validation to file upload control in asp.net



how to validate a file upload control to allow  maximum "100kB" Size images.if exceed it should fire a asp validation"file size must be 100KB maximum".


Many Thanks in Advance. 

Can't connect to local database file .mdf using SQL Server Authentication?


Using  - Visual Studio 2005 Professional, SQL Server 2005 Express, WinForms App

Problem - I am unable to connect to SQL Server local Database file (.mdf) through  SQL Server Authentication.

Description -

I am addding a SQL Database file (local) in the c# winapp solution by right-click -> add new item -> SQL database file.

It adds the file, starts a wizard to create datasets and tableAdapters. Dataset files (.xsd) are created in solution. In the Data Connection pane along ToolBox we can see Database1.mdf.

When i right click on databse1.mdf -> Modify Connection.

It shows a form with Test Connection option. The connection gets tested for Windows Auth.But for SQL Server Auth it shows following error message -

When User Instance = True

Error 1 "Failed to generate a user instance of SQL Server. Only an integrated sonnection can generate a user instance. The connection will be closed"

When i set User Instance = False it shows this message -

Error 2 "An Attemp to attach an auto-named database for file C:\Doc&Sett\Admin\MyDocs\VS2005\Projects\SamApp\SamApp\Database1.mdf failed. A database with the same name

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend