Posts

Return Image from Generic Handler that stored in Sql Server Database Varbinary Database Asp.Net C#

<%@ WebHandler Language="C#" Class="GalleryImg" %> using System; using System.Web; using System.Data; using System.Data.SqlClient; using System.IO; using System.Configuration; public class GalleryImg : IHttpHandler {     public void ProcessRequest(HttpContext context)     {         int id;         if (context.Request.QueryString["id"] != null || context.Request.QueryString["id"] != "")         {             id = Convert.ToInt32(context.Request.QueryString["id"]);             context.Response.ContentType = "image/jpeg";             Stream strm = DisplayImage(id);             byte[] buffer = new byte[2048];     ...

Save Image to SQL Server using varbinary,varbinary(Max) datatype

cn.Open(); SqlCommand cmd = new SqlCommand("Usp_InsertEvent", cn); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("Event_Name",TxtTitle.Text); cmd.Parameters.AddWithValue("Event_Description",TxtDescription.Text); Byte[] image1 = null; if (FileUpload1.HasFile && FileUpload1.PostedFile != null) {     HttpPostedFile File = FileUpload1.PostedFile;     image1 = new Byte[File.ContentLength];     File.InputStream.Read(image1, 0, File.ContentLength);     cmd.Parameters.AddWithValue("Image", image1); } else {     cmd.Parameters.Add("Photo1", SqlDbType.VarBinary).Value=DBNull.Value; } int x=cmd.ExecuteNonQuery(); cn.Close();
States in India Dropdown list ASP.Net < asp:DropDownList ID =" State" runat =" server" > < asp:ListItem > Andaman and Nicobar Islands < / asp:ListItem > < asp:ListItem > Andhra Pradesh < / asp:ListItem > < asp:ListItem > Arunachal Pradesh < / asp:ListItem > < asp:ListItem > Assam < / asp:ListItem > < asp:ListItem > Bihar < / asp:ListItem > < asp:ListItem > Chandigarh < / asp:ListItem > < asp:ListItem > Chattisgarh < / asp:ListItem > < asp:ListItem > Dadra and Nagar Haveli < / asp:ListItem > < asp:ListItem > Daman and Diu < / asp:ListItem > < asp:ListItem > Delhi < / asp:ListItem > < asp:ListItem > Goa < / asp:ListItem > < asp:ListItem > Gujarat < / asp:ListItem > < asp:ListItem > Haryana ...

Create HTML Report for C# Windows Form : Best Alternative to Crystal Report for Receipt Printing

Create HTML Markup and store to string variable : string part1 = "<!DOCTYPE html><html><head><style>table {border-collapse: collapse;}table, td, th {border: 1px solid black;}</style></head><body style='font-family:cambria;font-size:12px'><div  style='border-style:solid;border-width:1px;height:400px;text-align:center'><header style='bottom-border-style:solid;bottom-border-width:1px;bottom-border-color:#333'><span style='font-size:25px'>"; string part2 = CompanyName + "<br></span>";                 string part3 = CompanyAddress + "<hr style='color:#333'></header><div><table><tr ><td><b>INVOICE</b></td><td>" + InvoiceNo + "</td><td> <label style='padding-right:5%'><b>DATE</b></label></td><td><label style='paddin...
Asp.net c# code to Render Gridview Control   public override void VerifyRenderingInServerForm(Control control)     {         /* Verifies that the control is rendered */     } protected void BtnPayment_Click(object sender, EventArgs e)     {  using (StringWriter sw = new StringWriter())             {                 using (HtmlTextWriter hw = new HtmlTextWriter(sw))                 {                     GridViewCart.RenderControl(hw);                     StringReader sr = new StringReader(sw.ToString());                     string tablehtml = "GridView:<hr />" + sw.ToString();                 }     ...

Case in SQL

CASE ebv.db_no WHEN 22978 THEN 'WECS 9500' WHEN 23218 THEN 'WECS 9500' WHEN 23219 THEN 'WECS 9500' ELSE 'WECS 9520' END

Uploading Image to Sql Server Image Datatype in asp.net using fileupload Control

Uploading Image to Sql Server Image Datatype in asp.net using fileupload Control  Byte[] imgbyte = null;  if (FileUpload1.HasFile)             {                 string fileName = Path.GetFileName(FileUpload1.PostedFile.FileName);                 FileUpload1.PostedFile.SaveAs(Server.MapPath("~/UserPhoto/") + DateTime.Now.ToString("_MMddyyyy_HHmmss") + fileName);                 photo = "UserPhoto/" + DateTime.Now.ToString("_MMddyyyy_HHmmss") + fileName;                 string fpathPhoto = Server.MapPath(photo);                 FileInfo fInfo = new FileInfo(fpathPhoto);                 long numBytes = fInfo.Length;                 //Open FileStream to read...