|
Hi all, just want to find out what the best method would be.
I have a dataset with a datatable and values, now I want to write that to a xml file. Is it better to use xmlDocument for that or xmlwriter?
Thanks in advance
He who laughs last is a bit on the slow side
|
|
|
|
|
DataSet dset = new DataSet();
dset.WriteXml(path,null);
//this is the better idea
|
|
|
|
|
I knew there had to be an easy way
He who laughs last is a bit on the slow side
|
|
|
|
|
|
What I have done is to set up constraints on the dataset, but how do I catch any exception that are thrown? Which event do I need to check?
He who laughs last is a bit on the slow side
|
|
|
|
|
Hi,
I have two classes A and B, A will have subclasses A1 and A2, B will also have subclasses B1 and B2.
A1 and B1 will reference each other, as will A2 and B2. Think Controller and Window, where we have some commonality in the base classes but the subclasses will almost certainly have distinct behavior.
I wanted to design my classes so that the associations where declared in A and B (and inherited by the subclasses), putting the common properties (accessors etc) in the base classes, and initialising my derived classes with the necessary references. So A would contain a data member of type B with Property accessors, B would contain a data member of type A with Property accessors. When I created an instance of A1 I would supply it with an instance of B1, and supply B1 with a reference to A1.
As I now know/remembered this will not work seamlessly because I will only see the base class's members (not the derived class's). Virtual/Override kind of help but only to see methods that are defined on the base AND derived. My derived classes will have methods that should not have to appear on the base class in order to be seen.
So I am looking for the accepted C# best practice approach to implementing the above scenario.
Regards
|
|
|
|
|
Hello,
An interface will help you.
Search here on CP for Articles about the usage of interfaces!
All the best,
Martin
|
|
|
|
|
first - what is your problem , be more Specific.
if you don't know how to connect to a data base
then bye a book or use google
second - delete the previous posts before they kick your a**
When you get mad...THINK twice that the only advice
Tamimi - Code
|
|
|
|
|
Butt kicking mode activated.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
jus i want code for accessing MS- Access tables from windows forms in c#. dont excite ok?
|
|
|
|
|
mind ur language. ok?
|
|
|
|
|
easy easy.......
When you get mad...THINK twice that the only advice
Tamimi - Code
|
|
|
|
|
How to monitor an object in program ? When that object changes, I want to receive an event to do something.
Thank a lot.
imagic
|
|
|
|
|
Hello,
Make an property out of your object and fire your event in the properties setter, if the value changes.
private object _yourobject;
public object YourObject
{
get
{
return _yourobject;
}
set
{
if(value!=_yourobject)
{
_yourobject = value;
}
}
}
All the best,
Martin
|
|
|
|
|
One idea is to use the property (set and get)
EX:
public class testClass
{
public int s1 = 0;
public int s2 = 0;
public int s3 = 0;
}
private testClass Mumu=new testClass ();
public testClass mumu
{
set
{
MessageBox.Show("bingo");
Mumu = value;
}
get
{
MessageBox.Show("bingo");
return Mumu;
}
}
................
private void button2_Click(object sender, EventArgs e)
{
mumu.s1 = 10;
}
|
|
|
|
|
Sorry, my question isn't clear.
I have 2 programs A and B: program A monitors program B. When value of object in that program B changes, program B will receive event to do something.
Thanks a lot.
imagic
|
|
|
|
|
Hello,
What do you mean with "program"?
A class or an project?
All the best,
Martin
|
|
|
|
|
Martin# wrote: What do you mean with "program"?
A class or an project?
An independently running process is the general meaning of "program"
|
|
|
|
|
That's what I thougt, but I whanted to make sure if the question is asked correct.
Asking a question in a foreign language is often very difficult, as I know from myself.
But thank's for your statement.
All the best,
Martin
|
|
|
|
|
Thanks Martin.
I mean it be solution. It like a debug program (A) that monitor program (B).
Perhaps, I'll try server-client and get-set to do what I want. But, it isn't reasonable because we don't want to add too much code in solution (B)
Thanks you for your regard.
imagic
|
|
|
|
|
Hi,
I'm using Xmlreader to load XML and in the event that the server is down, to try another server. Below is snippets of the code:
foreach (System.Xml.XmlNode Addr in LinkAddr)
{
string link=Addr.Value.Tostring();
try
{
XmlReader reader = new XmlTextReader(link);
}
catch(system.net.webexception)
{
link=link.replace("AAA","XXX"); //replaces one server with another
XmlReader reader = new XmlTextReader(link);
}
finally
{
while (reader.Read())
{
switch (reader.NodeType)
{
case XmlNodeType.Element: ....
however, I get the error "The name 'reader' does not exist in the current context".
What should I do?One way I thought of is to put XmlReader reader=new XmlTextReader(link) in the finally block but will this result in waste of resource to load the page a second time after loading at either the try or catch block? I am new to c# and is using VS2005 with .NET 2.0. Thanks.
|
|
|
|
|
The problem is that you are declaring XmlReader reader in the try/catch blocks. Variables that are declared in these blocks cannot be seen in the finally section. What you need to do is declare reader before the try, so it becomes:
XmlReader reader = null;
try
{
reader = new XmlTextReader(link);
}
catch (WebException)
{
link = link.Replace("AAA","XXX");
reader = new XmlTextReader(link);
}
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Thanks. I believe it worked. Thanks.
|
|
|
|
|
Is there a generic adapter for collection that allows to map a colleciton of an object to e.g. a collection of members?
e.g. I have an IEnuemrable<ListViewItem> and want to turn this into an IEnumerable<object> holding the ListViewItem.Tag objects.
I toyed with writing a generic adapter IEnumerable<foo> to IEnumerable<bar> using a bar translate(foo f) delegate. But doing that for Enumerations, collections, ILists, ... involves a lot of generics, making my nice beautiful C# code look like template hell.
|
|
|
|
|
Hey!
I have a listview that gets filled with items which sometimes are updated. Every item gets a vlue in their tag-field. I was wondering if anyone knows of a very fast way of searching through these tags? My list can sometimes become pretty large why updating it takes a lot of time.
Best regards,
Hampus
|
|
|
|