|
You will need to define the InsertCommand property of the DataAdapter like so:
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.
/F - .NET Developer
|
|
|
|
|
Hi,
I was wondering if anyone knows if a .Net Control exists(free/commercial) which can let me have a view like this:
http://www.bergsoft.net/res/screenshots/next-grid/slides-style.gif
The Column headers at the top are not required. Thanks for any information, I am a bit new at this!
regards,
Brendan.
|
|
|
|
|
You can do things like that fairly easily with WPF. You'd use a listview as a starting point, then add a template for the list view items.
Infragistics controls did have something that could do similar to that in winforms last time I used them (a few years ago now).
Simon
|
|
|
|
|
Hi,
Is it possible to save event logs using C# ?
Any idea ?
Thansk in advance !!
cheers,
Abhijit
|
|
|
|
|
You could use the EventLog object to read the event log entries and then save them to a database or file, like so:
EventLog eventLog = new EventLog("Application");
foreach (EventLogEntry entry in eventLog.Entries)
Console.WriteLine(entry.Message);
/F - .NET Developer
modified on Wednesday, July 30, 2008 10:23 AM
|
|
|
|
|
Use Microsoft Enterprise Library for Event Log, Flat file logging or Error Logging.
|
|
|
|
|
Thanks for your response. but i want to save it ".evt" file.
cheers,
Abhijit
|
|
|
|
|
I don't believe the .NET Framework has native support for this, but you can try the following:
[DllImport("advapi32.dll")]
static extern IntPtr OpenEventLog(string lpUNCServerName, string lpSourceName);
[DllImport("advapi32.dll")]
static extern bool BackupEventLog(IntPtr hEventLog, string backupFile);
BackupEventLog(OpenEventLog("localhost", "Application"), @"C:\TEMP\EVENTLOG.EVT");
/F - .NET Developer
|
|
|
|
|
Thanks for your reply. I am trying to do it using WMI
cheers,
Abhijit
|
|
|
|
|
how do i set printer options? i would like to set these options
print from tray 1
pagesize 11x17
landscape
this is the code i am using
System.Drawing.Printing.PrintDocument pd = new System.Drawing.Printing.PrintDocument();
pd.PrinterSettings = printDialog1.PrinterSettings;
pd.PrinterSettings.Duplex = System.Drawing.Printing.Duplex.Simplex;
pd.DocumentName = "JP Council (Title Page)";
pd.PrintPage += new System.Drawing.Printing.PrintPageEventHandler(this.pd_PrintPage);
pd.Print();
i know it has to be something with the printersettings but just now sure how to do it
Thanks,
Chad Aiena
|
|
|
|
|
use
System.Drawing.Printing.PageSettings mySettings = new System.Drawing.Printing.PageSettings();
mySettings.PrinterSettings has everything you need.
Then apply mySettings to the System.Drawing.Printing.PrintDocument instance your using.
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
|
|
|
|
|
Hi i given in my form opacity=0 and set the form shown taskbar=false...,
To avoid form visible to my enduser...,
Now the probs is,
After my form load all the operations happend the form have to auto close?,
Its possible?,
Thanks & Regards,
NeW OnE,
please don't forget to vote on the post
|
|
|
|
|
Close();
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
|
|
|
|
|
Perhaps you don't want a Windows Application at all?
Have you considered a console application?
Either way, the user should have some indication that something happened.
|
|
|
|
|
Hi guys i created one windows application its contained only one form...,
In that form load event i said some operations have to run...,
Its working cool...,
But i dont like show the window form to enduser...,
It mean no minimize of the form also, just the form load operations have to run thats all
So i tried to hide that using this.hide(); methode in my form load event...,
But its not getting hide...,
how to hide my form window?
Thanks & Regards,
NeW OnE,
please don't forget to vote on the post
|
|
|
|
|
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.
DaveBTW, 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.
///
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
//Application.Run(new Form1());
MessageBox.Show("Test");
}
}
---------------------
I hope this helps.
-Dave.
--------------------------------
www.componentone.com
--------------------------------
------------------------------------
http://www.componentone.com
------------------------------------
|
|
|
|
|
You could set the forms opacity to 0
Regards,
Thomas Stockwell
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.
Visit my homepage Oracle Studios
Discounted or Free Software for Students:
DreamSpark - downloads.channel8.msdn.com
MSDN Academic Alliance - www.msdnaa.com
|
|
|
|
|
Hello gurus,
I have a problem to solve.
I'm using a set of standard named colors. When the user selects a given color lets say Red , I'd like to know how I can select programmatically the next colors to Red , that is Brown , FireBrick , etc.
The named colors are from the panel "Web" of the color selector.
I hope my question is clear enough.
Best regards.
Fred.
There is no spoon.
|
|
|
|
|
What do you mean be "next color to red"? What kind of structure do you use, an enumeration, a .NET defined enumeration?
Your question is a bit too vague.
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
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.
Fred.
There is no spoon.
|
|
|
|
|
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 .
|
|
|
|
|
I've had a look and it appears there is no emumeration available for the colours or tabs. The colours themselves (the names) are each public static read only properties that return a Color rather than an enum.
<EDIT>
System.Drawing.KnownColor is an enum of course!
</EDIT>
Using reflection I can loop through the properties and get the ones that are of type Color and exclude any that are SystemColor (WindowText etc...) but the list is alphabetical and not in the order you require (same as Web tab).
I think you'll have to hardcode your own list or enum and refer to the corresponding .Net colour from there.
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
|
|
|
|
|
Extending DaveyM69's advice, here's how you could go about getting the values you need:
PropertyInfo[] PropertyInfo = typeof(Color).GetProperties();
foreach (PropertyInfo propertyElement in PropertyInfo)
{
if (propertyElement.PropertyType == typeof(Color))
{
string colourName = propertyElement.Name;
Color c = Color.FromName(colourName );
}
}
Fernando Mendes
Senior .NET Developer, Architect
|
|
|
|
|
Ok, I have it.
Thanks guys
Fred.
There is no spoon.
|
|
|
|