|
My way is different, not necessarily better.
I'm going to take the code home tonight and run it under both VS2005 and VS2008, and see if I can duplicate the problem.
"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
|
|
|
|
|
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
|
|
|
|
|
i did a application that creates a new and empty database file(MDB file).
i want to create a new row in the new database.
i did this:
string connectionString = "provider=Microsoft.JET.OLEDB.4.0; " + "data source =" + Dir;
string commandString = "Select id,cell from Events";
OleDbDataAdapter dataAdapter = new OleDbDataAdapter(commandString, connectionString);
DataSet ds = new DataSet();
dataAdapter.Fill(ds, "Events");
DataTable datatable = ds.Tables[0];
DataRow newRow = datatable.NewRow();
newRow["id"] = "Gil";
newRow["Event"] = "Gil2";
datatable.Rows.Add(newRow);
dataAdapter.Update(ds, "Events");
ds.AcceptChanges();
it throws me a exception:
Update requires a valid InsertCommand when passed DataRow collection with new rows.
What is Wrong?..i am not understand
p.s
All of this is in try catch...
thank you!
|
|
|
|
|
you are not inserting new records. You are trying to update. But update what?
here this should help ^
Yusuf
|
|
|
|
|
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.
|
|
|
|