srikanth vanga

srikanth vanga

  • NA
  • 7
  • 4.2k

Windows Service

Dec 4 2012 7:41 AM
Hi Every One

I Have a Windows Service which gives me Build Secced But Am Unable to Debug it and Excute a Stored Procedure from My Windows Service Iam Using app.config for Stored Procedure
any Help Regarding  
How to Debugg a Windows Service?
How to Excute a stored Procedure from Windows Service?
 is appriciated


Here is My Code
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Linq;
using System.ServiceProcess;
using System.IO;
using System.Text;
using System.Timers;
using System.Data.SqlClient;
using System.Configuration;
namespace LogTimeJob
{
LogTimeJobpartial class LogTimeSyncJob : ServiceBase{
{
InitializeComponent();
}
{
Timer timer = new Timer();public LogTimeSyncJob()protected override void OnStart(string[] args)
TraceService(
timer.Elapsed +=
timer.Interval = 100000;
timer.Enabled =
}
{
"My Service Started at" + "_" + DateTime.Now);new ElapsedEventHandler(OnElapsedTime);true;public DataTable GetAttendanceDetails()DataTable dt = new DataTable();
{
cnn.Open();
using (SqlConnection cnn = new SqlConnection(strconn))
{
cmd.Connection = cnn;
cmd.CommandType =
cmd.CommandText = srtproc;
cmd.ExecuteNonQuery();
}
cnn.Close();
}
}
{
timer.Enabled =
TraceService(
}
{
TraceService(
GetAttendanceDetails();
}
{
{
file.WriteLine(content);
}
using (SqlCommand cmd = new SqlCommand())CommandType.StoredProcedure;return dt;protected override void OnStop()false;"My Service Stopped at " + "_" + DateTime.Now);private void OnElapsedTime(object source, ElapsedEventArgs e)" My Service Re-Started at " + "_" + DateTime.Now);private void TraceService(string content)using (System.IO.StreamWriter file = new System.IO.StreamWriter((srtfile), true))}
}
}
Thaks in Advance


Answers (1)