Click here to Skip to main content
15,908,444 members
Home / Discussions / C#
   

C#

 
AnswerRe: How to make the program do not minimized at all minimized windows? Pin
Slavik_ns21-Oct-11 3:02
Slavik_ns21-Oct-11 3:02 
QuestionCreate custom shaped buttons in WPF Pin
abyclassic20-Oct-11 20:01
abyclassic20-Oct-11 20:01 
AnswerRe: Create custom shaped buttons in WPF Pin
OriginalGriff20-Oct-11 21:32
mveOriginalGriff20-Oct-11 21:32 
AnswerRe: Create custom shaped buttons in WPF Pin
Abhinav S21-Oct-11 2:40
Abhinav S21-Oct-11 2:40 
GeneralRe: Create custom shaped buttons in WPF Pin
abyclassic23-Oct-11 22:29
abyclassic23-Oct-11 22:29 
QuestionDisplaying vertical rows to bind data Pin
AditSheth20-Oct-11 18:54
AditSheth20-Oct-11 18:54 
AnswerRe: Displaying vertical rows to bind data Pin
Richard MacCutchan20-Oct-11 21:43
mveRichard MacCutchan20-Oct-11 21:43 
QuestionCan someone please tell me why the eventlog part of this doesn't work? Pin
CCodeNewbie20-Oct-11 11:54
CCodeNewbie20-Oct-11 11:54 
Please forgive my desperate plea but I am trying to find out why the following code only half works.

My code
C#
namespace WindowsService1
{
    public partial class ServiceName : ServiceBase
    {
        public ServiceName()
        {
            InitializeComponent();
            string sSource;
            string sLog;
            string sEvent;

            sSource = "MyServiceName";
            sLog = "Application";
            sEvent = "MyServiceName starting";

            if (!EventLog.SourceExists(sSource))
                EventLog.CreateEventSource(sSource, sLog);

            EventLog.WriteEntry(sSource, sEvent);// this works
          
EventLog sysLog = new EventLog("System", ".");
sysLog.EntryWritten += new EntryWrittenEventHandler(OnEntryWritten);
EventLog.WriteEntry(sSource, "logger started");// this works too

Console.WriteLine("Logger started");// nothing writes to console
       }       

        public void OnEntryWritten(object source, EntryWrittenEventArgs e)
        {
string sSource;
            string sLog;
            sSource = "MyServiceName";
            sLog = "Application";
            if (!EventLog.SourceExists(sSource))
                EventLog.CreateEventSource(sSource, sLog);
           EventLog.WriteEntry(sSource, "sqllogger started");//this  doesn't work

SqlConnection Conn = new SqlConnection("User id = x; password = y; server=z;database=dbname;connection timeout=30");
            SqlCommand ins = new SqlCommand("INSERT INTO dbo.TableName(TimeWritten, Source)VALUES (@TimeWritten, @Source)", Conn);
            ins.Parameters.Add("@TimeWritten", SqlDbType.DateTime);
            ins.Parameters.Add("@Source", SqlDbType.NVarChar, 20);

            ins.Parameters["@TimeWritten"].Value = e.Entry.TimeWritten;
            ins.Parameters["@Source"].Value = e.Entry.Source;

            TableName.Open();
            ins.ExecuteNonQuery();
            TableName.Close();// nothing written to db
        }


The account the service runs under is a local admin on the Windows XP host.

Please could one of you Gurus tell me what I am doing wrong?
QuestionRe: Can someone please tell me why the eventlog part of this doesn't work? Pin
Luc Pattyn20-Oct-11 13:55
sitebuilderLuc Pattyn20-Oct-11 13:55 
AnswerRe: Can someone please tell me why the eventlog part of this doesn't work? Pin
CCodeNewbie20-Oct-11 21:51
CCodeNewbie20-Oct-11 21:51 
GeneralRe: Can someone please tell me why the eventlog part of this doesn't work? Pin
Luc Pattyn21-Oct-11 1:59
sitebuilderLuc Pattyn21-Oct-11 1:59 
AnswerRe: Can someone please tell me why the eventlog part of this doesn't work? Pin
BobJanova20-Oct-11 22:30
BobJanova20-Oct-11 22:30 
AnswerRe: Can someone please tell me why the eventlog part of this doesn't work? Pin
phil.o21-Oct-11 0:30
professionalphil.o21-Oct-11 0:30 
AnswerRe: Can someone please tell me why the eventlog part of this doesn't work? - Solved Pin
CCodeNewbie22-Oct-11 9:49
CCodeNewbie22-Oct-11 9:49 
QuestionI am having some basic compile issues defining a BorderBrush. Pin
Xarzu20-Oct-11 7:37
Xarzu20-Oct-11 7:37 
AnswerRe: I am having some basic compile issues defining a BorderBrush. Pin
Manfred Rudolf Bihy20-Oct-11 7:52
professionalManfred Rudolf Bihy20-Oct-11 7:52 
GeneralRe: I am having some basic compile issues defining a BorderBrush. Pin
Xarzu20-Oct-11 12:15
Xarzu20-Oct-11 12:15 
AnswerRe: I am having some basic compile issues defining a BorderBrush. Pin
Alisaunder20-Oct-11 18:34
Alisaunder20-Oct-11 18:34 
AnswerRe: I am having some basic compile issues defining a BorderBrush. Pin
BobJanova20-Oct-11 22:27
BobJanova20-Oct-11 22:27 
QuestionEmbedded Forms? Panels? Other? Pin
tim.walter20-Oct-11 3:33
tim.walter20-Oct-11 3:33 
AnswerRe: Embedded Forms? Panels? Other? Pin
Wayne Gaylard20-Oct-11 4:12
professionalWayne Gaylard20-Oct-11 4:12 
GeneralRe: Embedded Forms? Panels? Other? Pin
tim.walter20-Oct-11 4:20
tim.walter20-Oct-11 4:20 
GeneralRe: Embedded Forms? Panels? Other? Pin
Wayne Gaylard20-Oct-11 4:27
professionalWayne Gaylard20-Oct-11 4:27 
GeneralRe: Embedded Forms? Panels? Other? Pin
tim.walter20-Oct-11 4:30
tim.walter20-Oct-11 4:30 
GeneralRe: Embedded Forms? Panels? Other? Pin
BobJanova20-Oct-11 4:46
BobJanova20-Oct-11 4:46 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.