display resume to user in txt format
I have Stored my resume(wor开发者_高级运维d document) in my database.and i just want to show that resume in txt format to user. how can i show it to user?
I'm not that good in ASP.NET, but check the links below. Maybe it's not a solution, you want, but can be useful.
Save-Read-Image-Database
There isn't that much of difference, depending on what type to you use for your resume, a varchar or maybe varbinary.
How to Create a text file in ASP .NET
Reading and Writing Text Files with the .NET Framework
Tutorials on how to read/write a file in asp.net.
Good Luck!
UPDATE: So if it's a varbinary type, you can read as it was shown in first link. I'll paste a part with some changes.
connection.Open();
SqlCommand command1 = new SqlCommand("select <resume_content> from <resume_table> where id = @id", connection);
SqlParameter myparam = command1.Parameters.Add("@id", SqlDbType.Int);
myparam.Value = <your_value>
byte[] resume = (byte[])command1.ExecuteScalar();
MemoryStream str = new MemoryStream();
str.Write(resume, 0, resume.Length);
After that, just save the Stream to a file. Here's the link
Save a Stream to a File
UPDATE 2:
It's because you SELECT two columns. It takes FileName as the value for byte[]. For two columns you'd need to use ExecuteReader instead of ExecuteScalar.
Check this link
http://www.developerfusion.com/article/4278/using-adonet-with-sql-server/2/
Probably best to direct the user to download the document directly, and they can open it themselves.
精彩评论