Automatically Take Snap Shots Store in SQL DataBase Table Using WindowApplication C#

Automatically Take Snap Shots Store in SQL DataBase Table 

Automatically Take a Snap Shots  Store In Database Table as Well as Pc  Path Laocation Using Window Application C#.


http://dotnetdrizzles.blogspot.in/2015/04/automatically-take-snap-shots-capturing.html

http://dotnetdrizzles.blogspot.in/2015/04/capture-screen-shot-automatically-using.html




                                  DEMO



               
                             C# CODING


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace WindowsFormsApplication2
{
    public partial class ScreenCapture : Form
    {
        public ScreenCapture()
        {
            InitializeComponent();
        }

        private void ScreenCapture_Load(object sender, EventArgs e)
        {
            Timer timer = new Timer();
            timer.Interval = (1 * 10000); // 10 secs
            timer.Tick += new EventHandler(ScreenCapture_Load);
            timer.Start();
                      
            Bitmap bmp = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);
            using (Graphics g = Graphics.FromImage(bmp))
            {

                g.CopyFromScreen(0, 0, 0, 0, Screen.PrimaryScreen.Bounds.Size);

                bmp.Save(@"E:\New folder (2)\image.jpg");

                pictureBox1.Image = bmp;


                string date1 = DateTime.Now.Hour.ToString() + "_" + DateTime.Now.Minute.ToString() + "_" + DateTime.Now.Second.ToString() + "_" + DateTime.Now.Millisecond.ToString();
                string picname = "src";
                string path = Application.StartupPath.Substring(0, Application.StartupPath.LastIndexOf("bin"));
                Bitmap imgImage = new Bitmap(pictureBox1.Image);
        imgImage.Save(path + "\\file\\" + picname + "_" + date1 + ".jpg");

                SqlConnection  con = new SqlConnection(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=C:\Users\drizzle\Documents\Visual Studio 2012\WindowsFormsApplication2\WindowsFormsApplication2\Database1.mdf;Integrated Security=True");
                con.Open();
          SqlCommand cmd1 = new SqlCommand
            ("insert  into capture(imagename,imagepath)values('" + picname + "_" + date1 + "','" + "file/" + picname + "_" + date1 + "')", con);
                cmd1.ExecuteNonQuery();


            }
        }
    }
}



First - Add New Window Form - DataBase Table Fields Create 




Next - Add - Picture Box - From ToolBox -Add Folder To Solution Explorer






Next - Insert DataBase Fileds - Add Capturing Image To file   Folder - Save 






Next - Run[F5] - Automatically Capture Snap Shots - Show Picture box






Show Capturing Images - bin - File - Images





Next - Show The DataBase Table






0 comments:

Post a Comment