0

// i have made an application which get event logs from event viewer and store in a database, now I want to trigger that code when a specific event is logged // thi Code Get the Event log and Store it in databaSe...

try
    {
                    EventLog el = new EventLog();
                    el.Log = "Security";
                    el.MachineName = ".";
                    Query q = new Query();
                    foreach (EventLogEntry en in el.Entries )
                    {
                        if (if en.EventID==4688)
                        {
                            q.Insert("insert into EventLog (MachineName,Username,InstanceID,EventMsg,TimeGenerated) values ('" + en.MachineName + "', '" + en.UserName + "','" + en.InstanceId + "','" + en.Message + "','" + en.TimeGenerated + "')", q.Con());
                        }

                    }

                }
                catch (Exception x)
                {
                    MessageBox.Show(x.Message );
                }

0 Answers0