Click here to Skip to main content
14,741,152 members
Home » Discussions » C#
   

C#

 
GeneralRe: Kayan Yazı Pin
CHill6022-Oct-20 23:09
mveCHill6022-Oct-20 23:09 
GeneralRe: Kayan Yazı Pin
OriginalGriff22-Oct-20 23:14
mveOriginalGriff22-Oct-20 23:14 
QuestionInconveniente con la función MesageBox en C# Pin
Hernán Camilo21-Oct-20 9:50
professionalHernán Camilo21-Oct-20 9:50 
AnswerRe: Inconveniente con la función MesageBox en C# Pin
Richard MacCutchan21-Oct-20 23:02
mveRichard MacCutchan21-Oct-20 23:02 
GeneralRe: Inconveniente con la función MesageBox en C# Pin
jsc4223-Oct-20 0:28
professionaljsc4223-Oct-20 0:28 
GeneralRe: Inconveniente con la función MesageBox en C# Pin
Richard MacCutchan23-Oct-20 0:54
mveRichard MacCutchan23-Oct-20 0:54 
AnswerRe: Inconveniente con la función MesageBox en C# Pin
OriginalGriff23-Oct-20 2:13
mveOriginalGriff23-Oct-20 2:13 
QuestionApertura de Archivos en C# ASP.Net interactuando con base de datos SQL Server Pin
Hernán Camilo21-Oct-20 9:50
professionalHernán Camilo21-Oct-20 9:50 
Cordial saludo equipo de StackoverRun les escribe Hernán Martínez saludos desde Colombia, agradezco si me pueden colaborar acerca del inconveniente que tengo respecto a la apertura de archivos almacenados en una base de datos SQL server mediante el lenguaje de programación C# ASP.Net: 

El video explicativo de mi requerimiento es el siguiente:
https://www.youtube.com/watch?v=FGSGit5GjzY&feature=youtu.be

Y el código es el siguiente  

protected void gvContact5_SelectedIndexChanged(object sender, EventArgs e)  
   {
string IdMov = Convert.ToString(gvContact5.DataKeys[gvContact5.SelectedIndex].Value.ToString());
string query = "select * from compyrifas where idmov = @IdMov";
            var cmd = new SqlCommand(query, sqlCon5);
            cmd.Parameters.AddWithValue("@IdMov", IdMov);
            var DA5 = new SqlDataAdapter(cmd);
DataTable dtbl = new DataTable();
            DA5.Fill(dtbl);

            if ((dtbl.Rows.Count == 0) || (dtbl.Rows[0]["doc"] == DBNull.Value))
            {
                MessageBox.Show("Favor vuelva al formulario de Compras_y_rifas e inserte el correspondiente documento en el campo con nombre --Documento_escaneado-- para subir el documento");
            }
            else
            {
   string filenm = dtbl.Rows[0]["realname"].ToString();
    var doc = (byte[])dtbl.Rows[0]["doc"];
      Response.Charset = "";     

                 Response.Cache.SetCacheability(HttpCacheability.NoCache);

  if (filenm.Trim().EndsWith(".pdf"))
{
   Response.ContentType = "\".pdf\", \"application/pdf\"";
   Response.AddHeader("Content-disposition", "attachment; filename=" + filenm);        
    Response.BinaryWrite(doc);
    Response.End();
}    
   else if (filenm.Trim().EndsWith(".HTM") || filenm.Trim().EndsWith(".HTML"))
{
                
 Response.ContentType = "\".html\", \"application/html\"";
 Response.AddHeader("Content-disposition", "attachment; filename=" + filenm);
 Response.BinaryWrite(doc);
 Response.End();

}
   else if (filenm.Trim().EndsWith(".TIF"))
{
  Response.ContentType = "\".tiff\", \"application/tiff\"";
  Response.AddHeader("Content-disposition", "attachment; filename=" + filenm);
  Response.BinaryWrite(doc);
  Response.End();
}
else if (filenm.Trim().EndsWith(".jpeg") || filenm.Trim().EndsWith(".JPG"))
{
   Response.ContentType = "\".jpeg\", \"application/jpeg\"";
   Response.AddHeader("Content-disposition", "attachment; filename=" + filenm);
   Response.BinaryWrite(doc);
   Response.End();
}
else if (filenm.Trim().EndsWith(".doc") || filenm.Trim().EndsWith(".docx"))
{

  Response.ContentType = "\".doc\", \"application/msword\"";
  Response.AddHeader("Content-disposition", "attachment; filename=" + filenm);
  Response.BinaryWrite(doc);
  Response.End();
}

else if (filenm.Trim().EndsWith(".xls") || filenm.Trim().EndsWith(".xlsx")) 
 {
   Response.ContentType = "\".xls\", \"application/msexcel\"";
   Response.AddHeader("Content-disposition", "attachment; filename=" + filenm);
   Response.BinaryWrite(doc);
   Response.End();
}

else if (filenm.Trim().EndsWith(".accdb") || filenm.Trim().EndsWith(".mdb")) 
 {

 Response.ContentType = "\".accdb\", \"application/msAccess\"";
 Response.AddHeader("Content-disposition", "attachment; filename=" + filenm);
 Response.BinaryWrite(doc);
 Response.End();
 }
else if (filenm.Trim().EndsWith(".ppt") || filenm.Trim().EndsWith(".pptx"))
  {
 
 Response.ContentType = "\".ppt\", \"application/msPowerPoint\"";
 Response.AddHeader("Content-disposition", "attachment; filename=" + filenm);
 Response.BinaryWrite(doc);
 Response.End();

  }
}
}
Muchas gracias por su colaboración.

Att. Hernán Martínez
Bogotá D.C – Colombia 

AnswerRe: Apertura de Archivos en C# ASP.Net interactuando con base de datos SQL Server Pin
BillWoodruff21-Oct-20 16:30
mveBillWoodruff21-Oct-20 16:30 
QuestionGhost click mouse Pin
cloude8317-Oct-20 2:54
Membercloude8317-Oct-20 2:54 
AnswerRe: Ghost click mouse Pin
OriginalGriff17-Oct-20 3:16
mveOriginalGriff17-Oct-20 3:16 
GeneralRe: Ghost click mouse Pin
cloude8317-Oct-20 12:01
Membercloude8317-Oct-20 12:01 
AnswerRe: Ghost click mouse Pin
jsc4220-Oct-20 0:03
professionaljsc4220-Oct-20 0:03 
GeneralRe: Ghost click mouse Pin
trønderen20-Oct-20 6:54
Membertrønderen20-Oct-20 6:54 
Questionhi im a bit stuck i followed this tut on youtube and its just not working can anyone help me plz i get error Pin
Marcus Riggs14-Oct-20 13:32
MemberMarcus Riggs14-Oct-20 13:32 
AnswerRe: hi im a bit stuck i followed this tut on youtube and its just not working can anyone help me plz i get error Pin
OriginalGriff14-Oct-20 21:23
mveOriginalGriff14-Oct-20 21:23 
QuestionRe: hi im a bit stuck i followed this tut on youtube and its just not working can anyone help me plz i get error Pin
ZurdoDev15-Oct-20 2:18
professionalZurdoDev15-Oct-20 2:18 
Questionwhat is better way to handle audit data in sequel server? Pin
ronak752113-Oct-20 3:54
Memberronak752113-Oct-20 3:54 
AnswerRe: what is better way to handle audit data in sequel server? Pin
OriginalGriff13-Oct-20 3:57
mveOriginalGriff13-Oct-20 3:57 
AnswerRe: what is better way to handle audit data in sequel server? Pin
ZurdoDev13-Oct-20 4:12
professionalZurdoDev13-Oct-20 4:12 
AnswerRe: what is better way to handle audit data in sequel server? Pin
Richard MacCutchan13-Oct-20 6:24
mveRichard MacCutchan13-Oct-20 6:24 
GeneralRe: what is better way to handle audit data in sequel server? Pin
ZurdoDev14-Oct-20 6:21
professionalZurdoDev14-Oct-20 6:21 
GeneralRe: what is better way to handle audit data in sequel server? Pin
Richard MacCutchan14-Oct-20 6:39
mveRichard MacCutchan14-Oct-20 6:39 
QuestionWhat kind of dll use ftp/sftp mapping drive? Pin
Member 1336987112-Oct-20 23:48
MemberMember 1336987112-Oct-20 23:48 
AnswerRe: What kind of dll use ftp/sftp mapping drive? Pin
OriginalGriff13-Oct-20 2:54
mveOriginalGriff13-Oct-20 2:54 

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.