10/28/09

Create Event Viewer Log with System.Diagnostics.EventLog



Here's some code that will log a message in an event viewer:


EventLog EventLog1 = new System.Diagnostics.EventLog();

if (!EventLog.SourceExists("Name"))
EventLog.CreateEventSource(
"Name", "Application");

EventLog1.Source = "Name";
EventLog1.WriteEntry(message.ToString(), EventLogEntryType.Error);

10/27/09

@@identity equivalent in oracle



@@identity equivalent in oracle
Oracle uses sequences to generate unique values for identity columns. You can access the current identity value and the next value in SQL via these pseudocolumns :
  • CURRVAL: Returns the current value of a sequence

  • NEXTVAL: Increments the sequence and returns the next value

CURRVAL and NEXTVAL have to associated with a sequence. For example myTable_seq.CURRVAL or myTable_seq.NEXTVAL.

Connect to Oracle XE server from Oracle.DataAccess.Client

Here is the connection string to connect to an Oracle XE server:

"Data Source=//SERVERNAME/XE;" +
"User ID=USERNAME;" +
"Password=PASSWORD;";

Executing Multiple Inserts in Oracle


If you are inserting multiple inserts via a .net application you will need to format your inserts like so:

"begin insert into Task values(11,'tname');insert into
Task values(12,'tname');insert into Task values(13,'tname');insert into
Task values(14,'tname');end;";