Subscribe to Subscribers

Forums » .NET » ASP.NET »

Save file in daabase using vb.net


Posted Date: 14 Nov 2011      Posted By:: zafirah     Member Level: Bronze    Member Rank: 5499     Points: 2   Responses: 1



anyone know the code to save the file (.txt,.pdf) in the database (i'am using sql server 2005) and using language vb.net.. not only save the path of the file, but save the file also in the database..
Thanks guys..




Responses

#641893    Author: Kapil      Member Level: Gold      Member Rank: 50     Date: 14/Nov/2011   Rating: 2 out of 52 out of 5     Points: 4

Hi,

I am not sure if its good idea to store the file content in database but if it is requirement then it is fine to store.

I believe you have the column defined to store the data.

First thing, either you are using ADO.net or Entity Framework for the database, you should read the file.

Read the File



StreamReader read = new StreamReader("C:\\stp.log");
String content = read.ReadToEnd();


content has all the contents, now you can insert that into your database. I am giving snippet not whole code

insert into TextData(Data) values (content)

Happy Coding

"Please don't forget to Rate this answer if you found it usefull"

http://www.dotnetspider.com/mentors/86-kapil-deo.aspx
My Blog


 
Post Reply

 This thread is locked for new responses. Please post your comments and questions as a separate thread.
If required, refer to the URL of this page in your new post.



Next : How to retain the httpwebrequest state
Previous : Problem obtain detailsview control value
Return to Discussion Forum
Post New Message
Category:

Related Messages

Active Members
TodayLast 7 Daysmore...

Awards & Gifts
Talk to Webmaster Tony John
Copyright © SpiderWorks Technologies Pvt Ltd., Kochi, India
2005 - 2013 All Rights Reserved.
.NET and other trademarks mentioned in this site belong to Microsoft and other respective trademark owners.
Articles, tutorials and all other content offered here is for educational purpose only.
We are not associated with Microsoft or its partners.