Thursday, August 30, 2018

pest control Services in odisha | Sradha Webcreations | Manaswini Pest Control Services




Manaswini Pest Control Services

More Than10 Years Of WorkExperience






Manaswini Pest Control Services provider all House hold pest Control in Twin Cities. We are well known for our efficient services and on time delivery. We offer innovative pest control solutions for both residential and commercial spaces.

 

Ø     Termite Control (Post & Pre)

Ø     Rodent Control

Ø     Fly Control

ØCockroach Control

ØWeed Control

ØLizard Control

ØMosquitoes Control

ØBug Buster Service

 

Our Prices & Special Discounts
 NOW OFFERING THE BEST CASH DISCOUNT IN THE AREA 7% OFF !!!

 


by
http://sradhawebcreations.com/
+91-9937614595, +91-9348139624, +91-9668330437
Infront of Ultra Hospital,Near Axis Bank , Jagatpur Cuttack-754021, Odisha.

 


Sunday, August 26, 2018

how to store images in image datatype in sql server | Sradha WebCreations

how to store images in image datatype in sql server


HttpHandler.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="HttpHandler.aspx.cs" Inherits="HttpHandler" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>

       Enter ID&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox><br />
       Enter Name&nbsp;&nbsp; <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox><br />
        Select image&nbsp;  <asp:FileUpload ID="FileUpload1" runat="server" /><br />
       &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
       <asp:Button ID="Button1" runat="server" Text="Save" onclick="Button1_Click" /><br />

       <asp:Image ID="Image1"  runat="server" Height="137px" Width="130px" /><br />
       
        <asp:DropDownList ID="TextBox3" runat="server">
        </asp:DropDownList>
       
        <asp:Button ID="Button2" runat="server" Text="Search" onclick="Button2_Click" />

    </div>
    </form>
</body>
</html>

HttpHandler.aspx.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Data.SqlClient;
using System.Data;
using System.Web.UI.WebControls;
using System.Configuration;

public partial class HttpHandler : System.Web.UI.Page
{
    //static SqlConnection con = new SqlConnection(@"Data Source=.\SQLEXPRESS;AttachDbFilename=E:\websites\HttpHandlerDemo\App_Data\Database.mdf;Integrated Security=True;User Instance



Wednesday, August 22, 2018

how to upload file in web server using file zilla | Sradha WebCreations

how to upload html , CSS, folders, pictures, js files, web.config file, global.ashx file other file in web server using file zilla


Enter the host name , enter user name, password, account name….then click on connect..

now file zilla is connected to server , select your domain name double click on it


Open the website folder… present in the system.  Select the files and folders from your system drag and drop that file to the filezilla server loacation area.

After drop that files in the server location area of filezilla…right click on the first file …click on process to queue….


After successfully transfer the files to server open the web site…



http://pasupatigroup.com/




how to save image in binary format in asp.net & Sql Server | sradha Webcreations

how to save image in binary format  in asp.net & Sql Server also retrieve same images 


ImageSave.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="ImageSave.aspx.cs" Inherits="ImageSave" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    <table>
<tr>
<td>
    SomeText</td>
<td>
    <asp:TextBox ID="TextBoxSomeText" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td>
Image Name:
</td>
<td>
<asp:TextBox ID="txtImageName" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td>
Upload Image:
</td>
<td>
<asp:FileUpload ID="fileuploadImage" runat="server" />
</td>
</tr>
<tr>
<td>
</td>
<td>
<asp:Button ID="btnUpload" runat="server" Text="Upload" onclick="btnUpload_Click" />
</td>
</tr>
</table>
    </div>
    <div>
<!--<asp:gridview id="GridView1" runat="server" autogeneratecolumns="False">
       <columns>

           <asp:boundfield datafield="ImagePath" headertext="Header Text"></asp:boundfield>
           <asp:templatefield headertext="Image Form DataBase">

               <itemtemplate>
                   <img alt="Image" height="70px" src="<%# "ImageHandler.ashx?Id="+ Eval("id") %>" width="70px"/>
               </itemtemplate>
           </asp:templatefield>

       </columns>
   </asp:gridview>-->


   <asp:DataList ID="Datalist1" runat="server"  Width="100px" RepeatColumns="1">
   <ItemTemplate>
   <img alt="Image" height="70px" src="<%# "ImageHandler.ashx?Id="+ Eval("id") %>" width="70px"/>
   </ItemTemplate>
      </asp:DataList>
</div>
    </form>
</body>
</html>

ImageSave.aspx.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Security;

public partial class ImageSave : System.Web.UI.Page
{
    string strcon = ConfigurationManager.ConnectionStrings["dbconnection"].ConnectionString;
    protected void Page_Load(object sender, EventArgs e)
    {
        LoadData();
    }
    private void LoadData()
    {
        string returnValue = string.Empty;

        //Get the databse connection string from web.config file

        string conString = ConfigurationManager.ConnectionStrings["dbConnection"].ConnectionString;
        SqlConnection sqlConn = new SqlConnection(conString);
        SqlDataReader sqlDr = null;
        try
        {

            SqlCommand sqlCmd = new SqlCommand("GetImageInfoFromDB", sqlConn);
            sqlCmd.CommandType = CommandType.StoredProcedure;

            sqlConn.Open();
            sqlDr = sqlCmd.ExecuteReader();
            //Bind gridView

            //GridView1.DataSource = sqlDr;
            //GridView1.DataBind();

            Datalist1.DataSource = sqlDr;
            Datalist1.DataBind();
        }

        catch (Exception ex)
        {
            //Handle Error

        }
        finally
        {

            if (sqlDr != null && !sqlDr.IsClosed)
            {

                sqlDr.Close(); //close sqldatareader

            }

            sqlConn.Close();
        }
    }

    protected void btnUpload_Click(object sender, EventArgs e)
    {
        //Condition to check if the file uploaded or not
        if (fileuploadImage.HasFile)
        {
            //getting length of uploaded file
            int length = fileuploadImage.PostedFile.ContentLength;
            //create a byte array to store the binary image data
            byte[] imgbyte = new byte[length];
            //store the currently selected file in memeory
            HttpPostedFile img = fileuploadImage.PostedFile;
            //set the binary data
            img.InputStream.Read(imgbyte, 0, length);
            string imagename = txtImageName.Text;

            img.InputStream.Read(imgbyte, 0, length);
            string SomeText = TextBoxSomeText.Text;
            //use the web.config to store the connection string
            SqlConnection connection = new SqlConnection(strcon);
            connection.Open();
            SqlCommand cmd = new SqlCommand("INSERT INTO Image_Binary (SomeText,ImagePath,Image_Blob) VALUES (@SomeText,@ImagePath,@Image_Blob)", connection);
           
            cmd.Parameters.Add("@SomeText",SqlDbType.VarChar,50).Value=SomeText;
            cmd.Parameters.Add("@imagePath", SqlDbType.VarChar, 50).Value = imagename;
            cmd.Parameters.Add("@image_Blob", SqlDbType.Image).Value = imgbyte;
            int count = cmd.ExecuteNonQuery();
            connection.Close();
            if (count == 1)
            {
              //  BindGridData();
                txtImageName.Text = string.Empty;
                ScriptManager.RegisterStartupScript(this, this.GetType(), "alertmessage", "javascript:alert('" + imagename + " image inserted successfully')", true);
            }
        }
    }
   
}
ImageHandler.ashx
<%@ WebHandler Language="C#" Class="ImageHandler" %>

using System;
using System.Web;
using System.Data.SqlClient;
using System.Data;
using System.Configuration;


public class ImageHandler : IHttpHandler
{

    public void ProcessRequest(HttpContext context)
    {
        // context.Response.ContentType = "text/plain";
        //context.Response.Write("Hello World");

        string strId = context.Request.QueryString["Id"];
        if (!string.IsNullOrEmpty(strId))
        {
            SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["dbConnection"].ConnectionString);
            SqlDataReader sqlDr = null;
            try
            {
                conn.Open(); //open database connection

                SqlCommand sqlCmd = new SqlCommand("GetImageFromDB", conn);
                sqlCmd.CommandType = CommandType.StoredProcedure;

                //Add the parameter to SQLCommand object
                sqlCmd.Parameters.AddWithValue("@id", strId);
                sqlDr = sqlCmd.ExecuteReader();
                sqlDr.Read();
                context.Response.BinaryWrite((Byte[])sqlDr[3]);
                context.Response.End();

            }

            catch (Exception ex)
            {
                //Handle error If occured
            }
            finally
            {

                if (sqlDr != null && !sqlDr.IsClosed)
                {

                    sqlDr.Close(); //close SqlDataReader

                }

                conn.Close();//close database connection

            }
        }

    }
  
    public bool IsReusable
    {

        get
        {

            return false;

        }

    }

}

 Create 1 Procedures
Connect to ImageSave.aspx.cs for all data retrive from data base
SqlCommand sqlCmd = new SqlCommand("GetImageInfoFromDB", sqlConn);
CREATE PROCEDURE GetImageInfoFromDB

AS

BEGIN
 SELECT  id,SomeText,ImagePath,Image_Blob FROM dbo.Image_Binary
END



Create second procedure
Connect To ImageHandler.ashx for single data retrive

SqlCommand sqlCmd = new SqlCommand("GetImageFromDB", conn);

CREATE PROCEDURE GetImageFromDB(@id int)

AS

BEGIN



 SELECT  id,SomeText,ImagePath,Image_Blob FROM dbo.Image_Binary WHERE id = @id



END

After that  ImageHandler.ashx is called in ImageSave.aspx  datalist view/ grid view page
   <asp:DataList ID="Datalist1" runat="server"  Width="100px" RepeatColumns="1">
   <ItemTemplate>
   <img alt="Image" height="70px" src="<%# "ImageHandler.ashx?Id="+ Eval("id") %>" width="70px"/>
   </ItemTemplate>
      </asp:DataList>


 #SradhaWebCreations
Contact : +91-9040573923, +91-7008182025 http://sradhawebcreations.com/ http://sradhawebcreations.blogspot.in/ https://facebook.com/sradhawebcreations https://www.facebook.com/Sradhawebeducation/