|
Hi,
I am wondering if I create a diffgram dataset and I save the dataset to file and then want to commit the dataset to the database. I would assume that I would use a DataAdapter to help commit changes to db, correct?
Is there any special command in the DataAdapter in order to save dataset to database outside of the Update command? Like in the Update property is there any special option type that needs to be included in order to inform the DataAdapter what I am trying to accomplish?
Will a diffgram dataset work for Access as well as Sql Server?
Thanks,
JJ
|
|
|
|
|
MrJJKoolJ wrote:
Is there any special command in the DataAdapter in order to save dataset to database outside of the Update command?
I think you are talking about DataSet.GetChange() method. Also take a look at DataSet.Merge() , DataSet.Copy() too.
Mazy
"A useless but amusing fact is that if all the DNA in all the cells in a single human being were stretched out it would reach the moon and back eight thousand times." - Steve Jones
|
|
|
|
|
i want to create a live web radio station and i dont know where to start
pls help
cristiansje@yahoo.com
|
|
|
|
|
If you're familiar with programming you could investigate other sources (in different languages, like C++ and Delphi) if you can find any.
|
|
|
|
|
i didnt find any code for this this why i asked about it
|
|
|
|
|
I know people who have had success using http://www.shoutcast.com/ but I dont know much about it myself.
Good luck.
|
|
|
|
|
i know about them but need some basic concepts
|
|
|
|
|
As a MFC programmer I got used to be able to specify an UpdateCommandUI command handler that would take care of enabling/disabling my toolbar buttons and menu items, setting checkmarks in front of menuitems, select correct push buttons in toolbars etc. Is there any mechanism similar to this in .NET? I haven't been able to figure it out, or do I have to hard code this behaviour into every single event handler that's relevant?
Wenn ist das Nunstück git und Slotermeyer? Ja! Beierhund das oder die Flipperwaldt gersput!
|
|
|
|
|
dabs wrote:
do I have to hard code this behaviour into every single event handler that's relevant?
Write seprate method which update controls and simply call it whenever you need updating.
Mazy
No sig. available now.
|
|
|
|
|
|
Uwe Keim wrote:
You missed the "call" word
Corrected now.
Uwe Keim wrote:
but surely it is quite inefficient if you have large number of controls to update.
Yes, but I don't think any other way exists in C#.
Uwe Keim wrote:
I think MFC's version only call the apropriate handlers that are really needed (e.g. only the contents of ONE dropdown menu).
Its a long time that I haven't use MFC , but as muuch as I remeber it was not act like this too.
Mazy
"A useless but amusing fact is that if all the DNA in all the cells in a single human being were stretched out it would reach the moon and back eight thousand times." - Steve Jones
|
|
|
|
|
Has anyone ran into this before? When I try to load a xfdf into the ocx the control stops responding. The reader.exe has full support for xfdf, so I have not idea what to think.
|
|
|
|
|
I have a small library witch contains a few controls and one simple class. The class holds a vew variables and functions that the controls need and also manipulates with the controls itself (changes their text and color for example).
MyOwnPropertiesClass <---- Ctrl1/2/3 connect to this class.
| | |
Ctrl1 Ctrl2 Ctrl3
Because all controls in library exchange information through that one class, there must be only one instance of that class. It should be created just when the library is initialized or something like that. How is it possible ?
Best regards, Desmond
|
|
|
|
|
Create a singleton. Here's how:
Create a private static member variable of your class of the same type as your class and call it singleInstance or similar.
Create a static initialiser which is like a normal constructor but with the keyword static in front of it. In this method create a new instance of the class and assign it to the singleInstance member variable.
Modify your constructor so that it is private . This ensures that no one else can create your class.
Create a new static public get property called Instance or similar and return the singleInstance member variable.
The remainder of the class is as you would normally have it.
You have now created a singleton. Every time you want to use the class you access it through the Instance property. This version of a singleton will be created at application start up.
If you want to delay the initialisation until first use then you can remove the static initialiser and have the code for the Instance property check singleInstance == null in which case a new instance of the class is created and assigned to singleInstance first. Then it returns singleInstance as it did before.
Does this help?
--Colin Mackay--
EuroCPian Spring 2004 Get Together[^]
"You can have everything in life you want if you will just help enough other people get what they want." --Zig Ziglar
|
|
|
|
|
Thanks, this seems to be exacly what I need. However, could You please show me a little (code) example of a static initializer ?
And -- Where could I find more info on static initializers ? I did a quick search, but didn't result much...
Regards, Desmond
|
|
|
|
|
desmond5 wrote:
Where could I find more info on static initializers ?
Sorry, my fault - I was using Java terminology. In C# they are actually called static constructors. See this MSDN document[^]
[Edit]Ooops! I fixed some bugs[/Edit]
public MySingletonClass
{
private static MySingletonClass onlyInstance;
static MySingletonClass()
{
onlyInstance = new MySingletonClass();
}
public MySingletonClass()
{
}
public MySingletonClass Instance
{
get
{
return onlyInstance;
}
}
}
--Colin Mackay--
EuroCPian Spring 2004 Get Together[^]
"You can have everything in life you want if you will just help enough other people get what they want." --Zig Ziglar
|
|
|
|
|
Thanks. I also learned that these singletons has something to do with thread-safety (has something to do with multithreading) ... is this code compatible with that ?
|
|
|
|
|
desmond5 wrote:
singletons has something to do with thread-safety
I don't see why it cannot be used in a thead safety mechanism. However I've never used a singleton for that purpose.
For instance if you have a singleton that controls access to a shared resource then in each of you instance methods and properties (not the static ones) you can lock(this) to ensure that not other thread has access to your singleton while some sensitive operation is being carried out. See MSDN[^] for more information.
--Colin Mackay--
EuroCPian Spring 2004 Get Together[^]
"You can have everything in life you want if you will just help enough other people get what they want." --Zig Ziglar
|
|
|
|
|
Or a shorter version:
public MySingletonClass{
public static readonly MySingletonClass Instance = new MySingletonClass();
private MySingletonClass()
{
}
}
Have a look at my latest article about Object Prevalence with Bamboo Prevalence.
|
|
|
|
|
public (static) fields EVIL!!!!!!
--Colin Mackay--
EuroCPian Spring 2004 Get Together[^]
"You can have everything in life you want if you will just help enough other people get what they want." --Zig Ziglar
|
|
|
|
|
|
Arjan Einbu wrote:
The readonly keyword makes it work exactly the same way as the property getter.
If all you do in the property getter is return the member variable (field) then there isn't much difference.
As an absolute rule I never ever under any circumstances reveal the member variables of a class as public. Readonly or not. It breaks the OO rule on encapsulation.
What if you change the design of the class later on? You've publicly exposed the inner workings of the class! Using properties you can hide the inner workings, you can implement lazy lookup (my second suggestion employed a form of lazy lookup - the singleton is not created until needed), the innards of the class can change and the code for the property can coerce the expected value out so that existing code doesn't notice the difference.
--Colin Mackay--
EuroCPian Spring 2004 Get Together[^]
"You can have everything in life you want if you will just help enough other people get what they want." --Zig Ziglar
|
|
|
|
|
Colin Angus Mackay wrote:
If all you do in the property getter is return the member variable (field) then there isn't much difference.
You did in your example... ;)
I know the rules of OO, but i believe rules can be broken sometimes if it serves a greater purpose. (Less code, fewer sources of error, greater maintainability.)
You're absolutely right that you might want to change your code later on, and if other assemblies access my field, they will need to be recompiled if that field later on is changed to a property. So if some other assemblies are going to use that singleton, one should consider wrapping it up in a property, as you say, Colin.
(Also, public fields cannot be made part of an interface definition, so there can be several reasons to make it a property.)
However, if the field is accessed only from within the same assembly (or assemblies that are compiled together with the containing assembly) it will make no difference if you change the field to a property. This is very often the case. (Though one should perhaps mark the property as internal instead of public in that case.)
Encapsulation is preserved i this construct. By making the instance constructor private, we make sure there will be made no other instances of the singleton.
Revealing the inner workings on this construct wont do any harm. The knowledge gained from it can't be abused to access inner data in other ways than the way we planned for.
Have a look at my latest article about Object Prevalence with Bamboo Prevalence.
|
|
|
|
|
Arjan Einbu wrote:
I know the rules of OO, but i believe rules can be broken sometimes if it serves a greater purpose. (Less code, fewer sources of error, greater maintainability.)
Many years ago I worked with a programmer that would take this statement and abuse it to the extent that everything would be public! He'd interpret it as: Less code == fewer sources of error == greater maintainability
You make a very good argument in this case for allowing the public readonly field. However by the time I thought through all the possible senarios for each member variable I create and decide whether to fully encapsulate it or decide that it is safe to expose I could have written a default compliment of getters/setters for them.
--Colin Mackay--
EuroCPian Spring 2004 Get Together[^]
"You can have everything in life you want if you will just help enough other people get what they want." --Zig Ziglar
|
|
|
|
|
Colin Angus Mackay wrote:
Many years ago I worked with a programmer that would take this statement and abuse it to the extent that everything would be public!
Well, he didn't get it... neither about OO or maintainability.
I hope you understood it the way i meant it...
And yes; Creating the getter for this one probably is better, and isn't that much work. (Virtually none with the right tools[^] )
Have a look at my latest article about Object Prevalence with Bamboo Prevalence.
|
|
|
|