Friday, April 27, 2012

View File in asp.net with c#


  int docId = Convert.ToInt32(Request.QueryString["Id"]);
        if (cls.con.State == ConnectionState.Closed)
        {
            cls.con.Open();
        }
        SqlCommand cmd = new SqlCommand();
        cmd.Connection = cls.con;
        cmd.CommandText = "Select * from mail where Id = @Id";
        cmd.Parameters.Add("@Id", SqlDbType.Int);
        cmd.Parameters[0].Value = docId;
        SqlDataReader dr = cmd.ExecuteReader();


        if (dr.Read())
        {

            b = ((byte[])(dr["FileContent"]));
        }
        cls.con.Close();

        Response.BinaryWrite(b);
        Response.End();

1 comment:

Unknown said...

here class file and database is not available and because of that there's error in connection string. so please upload/provide whole solution.

Using Authorization with Swagger in ASP.NET Core

 Create Solution like below LoginModel.cs using System.ComponentModel.DataAnnotations; namespace UsingAuthorizationWithSwagger.Models {     ...