Title: windows services from DB1 to DB2                                 If you need copy same format use firefox or chrome or safari but iexplorer not work


Preview of Code
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Linq;
using System.ServiceProcess;
using System.Text;
using System.Data.SqlClient;
 
 
namespace FingerPrintService
{
    public partial class FingerPrintDaily : ServiceBase
    {
        public FingerPrintDaily()
        {
            InitializeComponent();
        }
 
        protected override void OnStart(string[] args)
        {
            timer_fingerprint.Start();
 
            using (System.IO.StreamWriter file =
            new System.IO.StreamWriter(@"C:\finger.txt", true))
            {
                file.WriteLine("service started " + DateTime.Now.ToString());
            }
        }
 
        protected override void OnStop()
        {
        }
 
        private void timer_fingerprint_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
        {
            try
            {
 
                /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
                SqlConnection Con_Actatek = new SqlConnection("Server=172.16.30.27;Database=Actatek_Baladiyats;User ID=sa;Password=Aa123123");
 
                SqlCommand cmd_Actatek = new SqlCommand("SelectNewRecords");
                cmd_Actatek.Connection = Con_Actatek;
                cmd_Actatek.CommandType = CommandType.StoredProcedure;
                SqlDataAdapter adp_Actatek = new SqlDataAdapter(cmd_Actatek);
 
                DataTable dt_Actatek = new DataTable();
                DataTable dt_Location = new DataTable();
                adp_Actatek.Fill(dt_Actatek);
                cmd_Actatek.CommandText = "SelectLocation";
 
                adp_Actatek.Fill(dt_Location);
 
                SqlCommand cmd_Update_Actatek = new SqlCommand("UpdateTrans");
                cmd_Update_Actatek.CommandType = CommandType.StoredProcedure;
                cmd_Update_Actatek.Connection = Con_Actatek;
 
                //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
                SqlConnection Con_hadir = new SqlConnection("Server=172.16.30.27;Database=HadirDB;User=sa;Password=Aa123123");
 
                SqlCommand cmd_hadir = new SqlCommand("InsertNewRecordHadir");
                cmd_hadir.Connection = Con_hadir;
                cmd_hadir.CommandType = CommandType.StoredProcedure;
 
                Con_hadir.Open();
                Con_Actatek.Open();
 
                for (int i = 0; i < dt_Actatek.Rows.Count; i++)
                {
                    cmd_hadir.Parameters.Clear();
 
                    cmd_hadir.Parameters.AddWithValue("@EMPLOYEEID", dt_Actatek.Rows[i]["USERID"].ToString());
                    cmd_hadir.Parameters.AddWithValue("@DateTime", DateTime.Parse(dt_Actatek.Rows[i]["ActionDate"].ToString()).ToString("yyyy-MM-dd hh:mm:ss"));
                    cmd_hadir.Parameters.AddWithValue("@Type", dt_Actatek.Rows[i]["EVENTID"].ToString());
 
                    string LocationID = "";
                    for (int ii = 0; ii < dt_Location.Rows.Count; ii++)
                    {
                        if (dt_Location.Rows[ii]["LocationIP"].ToString() == dt_Actatek.Rows[i]["TERMINALIP"].ToString())
                        {
                            LocationID = dt_Location.Rows[ii]["Flag"].ToString();
                        }
                    }
 
                    cmd_hadir.Parameters.AddWithValue("@LocationID", LocationID);
 
                    try
                    {
                        int RowEf = cmd_hadir.ExecuteNonQuery();
                    }
                    catch (Exception ee)
                    {
                        using (System.IO.StreamWriter file =
               new System.IO.StreamWriter(@"C:\finger.txt", true))
                        {
                            file.WriteLine(ee.ToString());
                        }
                    }
 
                    cmd_Update_Actatek.Parameters.Clear();
                    cmd_Update_Actatek.Parameters.AddWithValue("@ID", dt_Actatek.Rows[i]["ID"].ToString());
                    cmd_Update_Actatek.ExecuteNonQuery();
 
                }
 
                Con_hadir.Close();
                Con_Actatek.Close();
            }
            catch (Exception ee)
            {
 
            }
        }
    }
}