Click here to Skip to main content
15,913,944 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hai to ALL...
can any one help me out in displaying the resume to the client when he clicks view ...
i retrieve using the the candidate ID(i.e email)
here is the code....


Collapse

C#
protected void Page_Load(object sender, EventArgs e)
   {
 
       SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["myconnection"].ConnectionString);
       string email = Session["email"].ToString();
       string query = "select resumeData,resumeContent,resumeName from Employee where email='" + email + "'";
       SqlCommand cmd = new SqlCommand(query, con);
       string strExtenstion="";
       string strName = "";
       UnicodeEncoding uniEncoding = new UnicodeEncoding();
       con.Open();
       SqlDataReader dr = cmd.ExecuteReader(CommandBehavior.Default);
     
       if (dr.Read())
       {
       
           byte[] imagecontent1 = (byte[])(dr["resumeData"]);
           int blen = ((byte[])dr["resumeData"]).Length;
 
       
 
         
        byte[] imagecontent = uniEncoding.GetBytes(imagecontent1.ToString().Replace("-",""));
          if (!dr["resumeContent"].Equals(System.DBNull.Value))
             
         strExtenstion = dr["resumeContent"].ToString();
          if (!dr["resumeName"].Equals(System.DBNull.Value))
 
              strName = dr["resumeName"].ToString();
 

 
          Response.Write("<pre>");
          Response.BinaryWrite(imagecontent1);
          Response.Flush();
          Response.Close();
          Response.Write("<pre>");
 
       }
       dr.Close();
          con.Close();        
 
   }
Posted
Updated 14-Apr-11 1:40am
v2

1 solution

What you're doing does not look very promising. You seem the read binary content from your DB and then write it out into the rendered HTML into a pre tag. BTW your closing pre tag should look like so </pre> and you really should move the Flush and Close invocation after the last write. Writing to a stream after closing it will generate an exception for sure.
If your DB does not contain text (as your usage implies) but rather some kind of document (Word, PowerOoint, Excel, etc.) you'd have to go different direction. Then you'd have to return a response header that has the correct mime type including the data in Base64 encoding.

Best Regards,

-MRB
 
Share this answer
 
v2
Comments
Sergey Alexandrovich Kryukov 15-Apr-11 0:25am    
Useful criticism. My 5.
--SA
Manfred Rudolf Bihy 15-Apr-11 4:09am    
Thanks SA!
I wouldn't even call that criticism, just pointing out some obvious mistakes. :)
Sergey Alexandrovich Kryukov 15-Apr-11 4:28am    
You're welcome.
No matter how you called it, but it's useful.

I fixed some obvious typo, hope you don't mind. I remember how you helped me in the same way.
--SA
Manfred Rudolf Bihy 15-Apr-11 4:41am    
Thanks SA and no I don't mind. :)
Manfred Rudolf Bihy 15-Apr-11 4:55am    
Helping and getting help, isn't that the true spirit of CP! :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900