Just so you know, I figured out how to fix it (and posted a new message about it in this forum).
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
You will need to define the InsertCommand property of the DataAdapter like so:
// Connection & DataAdapter initialization code should go here
OleDbCommand insertCommand = connection.CreateCommand();
insertCommand.CommandText = "Insert Into Table(Col1, Col2, Col3) Values (?, ?, ?)";
dataAdapter.InsertCommand = insertCommand;
You may also want to check out the UpdateCommand and DeleteCommand properties which will allow your adapter to update and delete records which is what it seems you are also trying to do in your code snippet.
You could use the EventLog object to read the event log entries and then save them to a database or file, like so:
// Opens the Application event log.
EventLog eventLog = new EventLog("Application");
// Iterate through the entries in the opened event log.
foreach (EventLogEntry entry in eventLog.Entries)
I don't believe the .NET Framework has native support for this, but you can try the following:
// Declare this at the class member space
static extern IntPtr OpenEventLog(string lpUNCServerName, string lpSourceName);
static extern bool BackupEventLog(IntPtr hEventLog, string backupFile);
// Somewhere in your code, call the above two declarations...
// NOTE: Replace "localhost" with the machine name you need to back up.
// Replace "Application" with the log you are trying to back up.
// The saved file is an EVT file.
BackupEventLog(OpenEventLog("localhost", "Application"), @"C:\TEMP\EVENTLOG.EVT");
You can put your code in the constuctor instead of load so it runs before the loading takes place unless you need to access the form itself (or child controls) as it's handle won't be created yet so the object(s) will be unavailable.
Dave BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
If your only purpose is to execute a piece of code and not to show any window, you can simply delete the form and put your code in Main method.
Open Program.cs file and under main function comment out line which shows the form, and put your code. Such as –
static class Program
/// The main entry point for the application.
static void Main()
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
When you look at the color picker, you have 3 tabs, one contains the names of the colors ("Web" tab).
When the user selects Red, I'd like to programatically go to the next color, that is Brown, FireBrick etc.
Enumerations are just numbers, so you can try cast to number (int/long whatever), increment it, then cast back. You should probably add some checking to see if the next number is indeed a valid enumeration name. There are other approaches too. Look at Enum.GetValues and Enum.GetNames.