Click here to Skip to main content
15,891,409 members
Home / Discussions / ASP.NET
   

ASP.NET

 
AnswerRe: retain scrollbar position Pin
Sandeep Mewara18-Jul-12 19:37
mveSandeep Mewara18-Jul-12 19:37 
AnswerRe: retain scrollbar position Pin
Rajesh Buddaraju19-Jul-12 6:25
Rajesh Buddaraju19-Jul-12 6:25 
GeneralRe: retain scrollbar position Pin
Sandeep Mewara19-Jul-12 17:39
mveSandeep Mewara19-Jul-12 17:39 
GeneralRe: retain scrollbar position Pin
Trak4Net21-Jul-12 11:02
Trak4Net21-Jul-12 11:02 
GeneralRe: retain scrollbar position Pin
Sandeep Mewara21-Jul-12 19:49
mveSandeep Mewara21-Jul-12 19:49 
QuestionHelp Pin
laxman sindh18-Jul-12 5:12
laxman sindh18-Jul-12 5:12 
AnswerRe: Help Pin
Sandeep Mewara18-Jul-12 9:28
mveSandeep Mewara18-Jul-12 9:28 
GeneralProblem saving file to MySQL Pin
Jassim Rahma18-Jul-12 3:35
Jassim Rahma18-Jul-12 3:35 
I am using this code to save file to MySQL but when I try to open the file after saving it I get an error saying:

Word was unable to read this document. It may be corrupt.


here is the code to write:

C#
// string
file_name = Path.GetFileName(uploadResume.PostedFile.FileName);
file_extension = Path.GetExtension(uploadResume.PostedFile.FileName);

switch (file_extension)
{
    case ".pdf": document_type = "application/pdf"; break;
    case ".doc": document_type = "application/vnd.ms-word"; break;
    case ".docx": document_type = "application/vnd.ms-word"; break;
    case ".gif": document_type = "image/gif"; break;
    case ".png": document_type = "image/png"; break;
    case ".jpg": document_type = "image/jpg"; break;
    case ".jpeg": document_type = "image/jpg"; break;
}

// calculate size of file;
int file_size = uploadResume.PostedFile.ContentLength;

// create array to read the file into it;
byte[] document_binary = new byte[file_size];
uploadResume.PostedFile.InputStream.Read(document_binary, 0, file_size);



and then passing it as parameters:

C#
sql_command.Parameters.AddWithValue("param_resume_format", document_type).MySqlDbType = MySqlDbType.VarChar;
sql_command.Parameters.Add("param_resume_data", MySqlDbType.Blob, file_size).Value = document_binary;


and here is how I am retrieving it:

C#
sql_connection = new MySqlConnection(ConfigurationManager.ConnectionStrings["SQLdb"].ConnectionString);
sql_connection.Open();
sql_command = new MySqlCommand("sp_get_resume_by_id", sql_connection);
sql_command.CommandType = CommandType.StoredProcedure;
sql_command.Parameters.Add("param_resume_id", MySqlDbType.Int32).Value = resume_id;
sql_reader = sql_command.ExecuteReader();
sql_reader.Read();

if (sql_reader.HasRows)
{
    file_name = sql_reader["resume_id"].ToString() + sql_reader["resume_ext"].ToString();
    byte[] document_binary = (byte[])sql_reader["resume_data"];

    FileStream file_stream = new FileStream(@"C:\Temp\" + file_name, FileMode.Create);
    file_stream.Write(document_binary, 0, document_binary.Length);
    file_stream.Close();
    file_stream.Dispose();

    txtResume.Visible = true;
}

GeneralRe: Problem saving file to MySQL Pin
Bernhard Hiller18-Jul-12 21:54
Bernhard Hiller18-Jul-12 21:54 
GeneralRe: Problem saving file to MySQL Pin
Jassim Rahma19-Jul-12 8:47
Jassim Rahma19-Jul-12 8:47 
QuestionPartialUpdatePanel with Dynamic UserControls Pin
vishnukamath18-Jul-12 2:36
vishnukamath18-Jul-12 2:36 
AnswerRe: PartialUpdatePanel with Dynamic UserControls Pin
Sandeep Mewara18-Jul-12 9:33
mveSandeep Mewara18-Jul-12 9:33 
AnswerRe: PartialUpdatePanel with Dynamic UserControls Pin
jkirkerx18-Jul-12 10:50
professionaljkirkerx18-Jul-12 10:50 
GeneralHow do I handle wrongly suffixed url of webpages? Pin
Ravi Sant18-Jul-12 1:47
Ravi Sant18-Jul-12 1:47 
AnswerRe: How do I handle wrongly suffixed url of webpages? Pin
Eddy Vluggen18-Jul-12 3:23
professionalEddy Vluggen18-Jul-12 3:23 
GeneralRe: How do I handle wrongly suffixed url of webpages? Pin
Ravi Sant19-Jul-12 9:46
Ravi Sant19-Jul-12 9:46 
GeneralRe: How do I handle wrongly suffixed url of webpages? Pin
ashjassi17-Aug-12 2:58
ashjassi17-Aug-12 2:58 
QuestionCreating a dynamic Survey Form from a database Pin
GStar99917-Jul-12 8:18
GStar99917-Jul-12 8:18 
AnswerRe: Creating a dynamic Survey Form from a database Pin
Christian Graus17-Jul-12 17:38
protectorChristian Graus17-Jul-12 17:38 
QuestionHow to Implement Virtual scroll grid view with fix header Pin
sumB17-Jul-12 5:12
sumB17-Jul-12 5:12 
AnswerRe: How to Implement Virtual scroll grid view with fix header Pin
Christian Graus17-Jul-12 17:39
protectorChristian Graus17-Jul-12 17:39 
GeneralUsing CKeditor (fck) with ASP.NET Pin
murad_3517-Jul-12 4:52
murad_3517-Jul-12 4:52 
GeneralRe: Using CKeditor (fck) with ASP.NET Pin
R. Giskard Reventlov17-Jul-12 5:35
R. Giskard Reventlov17-Jul-12 5:35 
GeneralRe: Using CKeditor (fck) with ASP.NET Pin
murad_3517-Jul-12 5:46
murad_3517-Jul-12 5:46 
GeneralRe: Using CKeditor (fck) with ASP.NET Pin
jkirkerx17-Jul-12 6:59
professionaljkirkerx17-Jul-12 6:59 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.