|
okay i want it to create a new set of elements like this: when i click this button it creates the xml file and the first element then when i click it again it adds the new elements to that xml file.
First Click of Button
<taxiq>
<taxi>
<userid>asfSFAas
<date>fdsafasdfdsa
Second Click
<taxiq>
<taxi>
<userid>code
<date>project
<taxi>
<userid>Da
<date>Intern
I'm completely lost!!
Da Intern
|
|
|
|
|
If you download this project, http://codeproject.com/csharp/CSPersonalOrganizer1.asp you'll see how I'm creating, reading, and writing data to an xml file. When my application opens, it will check to see if your xml file exists, if it does it will open the xml file, if it doesn't it will create one for you.
This should help you with your questions above.
|
|
|
|
|
In pseudocode:
if XML file exists
open the existing XML file in append mode
else
create XML file
add new XML elements
close XML file
Cheers, Julian
Program Manager, C#
This posting is provided "AS IS" with no warranties, and confers no rights.
|
|
|
|
|
Actually, even this simplistic model is broken, if you think about it.
An XML document has a root element. If you append more elements to an XML file you should appeand them within the root element; in other words, before the final . So if you had:
<root>
<element>
some data
</element>
</root>
and wanted to add another element, you'd have to end up with this:
<root>
<element>
some data
</element>
<element>
and yet more data
</element>
</root>
Interesting. Without parsing the entire XML document, this could be pretty complex. Possibly the best idea is to read the entire file as XML and then write it out again completely with the extra element(s).
Cheers, Julian
Program Manager, C#
This posting is provided "AS IS" with no warranties, and confers no rights.
|
|
|
|
|
Hi, I am not fully sure how to do the following, please help if you can. I have two tables (As far as I know I have not set a join between them). I need to view values from both tables (they have a common id, invProductID). The rule is, If a number I specify is in the first table, then show the values I want. However, I have not been able to get this to work. I am using a dataset and/or dataTables.
I know I can do this by updating the dataAdapter, but the problem is I cant do that until a later stage. If you need any more information, please let me know. Thanks in advance.
|
|
|
|
|
I suggest you create a typed dataset with both your tables in it. When you create a typed dataset, the typed dataset class will automatically include a method to find rows by the primary key. (Make sure the primary key is defined in all your tables in your dataset!)
For example, if your table is called "Product" and has "ProductID" as primary key, the typed dataset will provide a method called FindByProductID(int value).
You can iterate throuh the rows collection of your second table, get the productid of the current row and then go to the first table and retrieve the related record by calling FindByProductID.
That is 1 way of doing it without data relations.
Of course you could also create a data relation in your dataset, and use getchilds or getparent methods in the dataset to navigate along foreign keys.
:-OChris
|
|
|
|
|
Hi, I have done what you suggested, but having a problem in one final area. I need to load the new dataSet with information from an existing dataSet, I am trying to do something like :
prodInventoryDataSet1.products = generalDataSet.Tables["products"].Copy();
Of course, this does not work, I was wondering if there was a way to do it.
|
|
|
|
|
Try one of the Merge overloaded methods, something like
targetDataSet.Merge(sourceDataSet)
when you need the data from one dataset to be copied into one another.
Chris
|
|
|
|
|
DataColumn parentCol;
DataColumn childCol;
// Code to get the DataSet not shown here.
parentCol = DataSet1.Tables["Customers"].Columns["CustID"];
childCol = DataSet1.Tables["Orders"].Columns["CustID"];
// Create DataRelation.
DataRelation relCustOrder;
relCustOrder = new DataRelation("CustomersOrders", parentCol, childCol);
// Add the relation to the DataSet.
DataSet1.Relations.Add(relCustOrder);
Future belongs to C#!
|
|
|
|
|
I have a question about SoapForamter and BinaryFormater. When I use TchpChannel,BinaryFormater is used and when I use HttpChannel,Soapforamter is used.Can I change this beahavour and use SoapFormater for TcpChannel?
Mazy
No sig. available now.
|
|
|
|
|
Yes... definitely... the formatters are swappable.... you could even write your own!
Off the top of my head you simply substitute BinaryFormatter for SoapFormatter...
Below is the client config channels section...
<channels>
<channel ref="tcp">
<clientProviders>
<formatter ref="soap" />
</clientProviders>
</channel>
</channels>
As I understand it you don't need to do anything on the server side as the server TCP channel will use both formatters and detect which one you have used on the client side...
HTH
Shaun
-----------------------------------------------------------------------
Shaun Austin: .NET Specialist. Spreading the word of .NET to the world... well the UK... well my tiny corner of it!!
|
|
|
|
|
Woww...thanks.
Mazy
No sig. available now.
|
|
|
|
|
hmmm,Can I set this property programmically too?
Mazy
No sig. available now.
|
|
|
|
|
Sorry about the delay Mazy...
Yes you can do anything in code that can be done in the config files it just isn't always that obvious in the docs... to set up the Soap/tcp you would use something like...
ChannelServices.RegisterChannel(new TcpChannel(null, new SoapClientFormatterSinkProvider(), null));
HTH
Shaun
-----------------------------------------------------------------------
Shaun Austin: .NET Specialist. Spreading the word of .NET to the world... well the UK... well my tiny corner of it!!
|
|
|
|
|
Hi all,
All I want to do is click a button and keep it pressed, but there doesn't seem to be a btnButton.Pressed (or anything like) kinda value.
If anyone knows the solution, I'd be very grateful,
Cheers
Preacher
|
|
|
|
|
hi !
i hope thats the way the button should look like:
cmdButton.FlatStyle = FlatStyle.Flat;
andi
|
|
|
|
|
I know in MFC/C++ there's a way to simulate that by using a checkbox and making it look like a button. Let me do a quick check...
Yep, it seems like you can do the same in .NET. Add a checkbox and set the Appearance property to Button:
this.checkBox.Appearance = System.Windows.Forms.Appearance.Button;
Regards,
Alvaro
Hey! It compiles! Ship it.
|
|
|
|
|
When BeginInvoke() is called on a delegate with multiple event handlers registered, do all the event handlers get called synchronously in a single thread, or do they all get their own thread? Or can only one event handler be called for an asynchronous delegate?
I can't find this in the docs.
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
Ahh, asking a question in the C# forum! You know, I really ought to do a test on this one, but so far, it seems that they are each called on separate threads. But I know for sure that they all get called.
"Blessed are the peacemakers, for they shall be called sons of God." - Jesus
"You must be the change you wish to see in the world." - Mahatma Gandhi
|
|
|
|
|
Thanks Justin
I've managed to get asynchronous delegates working in C++, but I've had to use the inline assembler . It works nicely though
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
Ryan Binns wrote:
Thanks Justin
Ryan Binns wrote:
I've managed to get asynchronous delegates working in C++
Congrats!
Ryan Binns wrote:
but I've had to use the inline assembler
That's what it's good for - doing things that either you can't do very well otherwise, or that are too slow otherwise.
BTW, there's now a GotDotNet Workspace[^] for Fluid, and I've got some ASP.NET hosting.
"Blessed are the peacemakers, for they shall be called sons of God." - Jesus
"You must be the change you wish to see in the world." - Mahatma Gandhi
|
|
|
|
|
jdunlap wrote:
That's what it's good for - doing things that either you can't do very well otherwise, or that are too slow otherwise.
Or doing things that are impossible - stack manipulation
jdunlap wrote:
there's now a GotDotNet Workspace[^] for Fluid
I've just applied for membership, so you should get something soon...
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
Ryan Binns wrote:
I've just applied for membership, so you should get something soon...
...and you've just gotten membership!
"Blessed are the peacemakers, for they shall be called sons of God." - Jesus
"You must be the change you wish to see in the world." - Mahatma Gandhi
|
|
|
|
|
I have written .NET remoting project and am looking for a way to know when each and every instance of a SingleCall/Singleton object is created and destroyed.
Does anyone know how to do this?
|
|
|
|
|
I don't know much about remoting but the idea of a singelton is that there will only be one instance of it during the lifetime of the application. This is usually accomplished by making the varaible a static. Note that there will really only ever be just 1 instance of your Singleton if that is the case.
One approach is to have a static tracker that is incremented in the constructor of your Singleton class and decremented in the destructor.
Ex:
class SingleFella
{
private static int tracker = 0;
private static SingleFella m_instance = null;
public static SingleFella GetInstance()
{
if( m_instance == null )
m_instance = new SingleFella();
return m_instance;
}
public static void DestroyInstance()
{
m_instance = null;
}
private SingleFella()
{
tracker++;
System.Console.WriteLine("Tracker (Constructor)= " + tracker);
}
~SingleFella()
{
tracker--;
m_instance = null;
System.Console.WriteLine("Tracker (Destructor)= " + tracker);
}
public static void Main(String [] args)
{
SingleFella instance1 = SingleFella.GetInstance();
SingleFella instance2 = SingleFella.GetInstance();
SingleFella instance3 = SingleFella.GetInstance();
SingleFella instance4 = SingleFella.GetInstance();
SingleFella.DestroyInstance();
}
}
Give that sample a run and move around the call to DestroyInstance() and you will see the effect.
I'm not quite sure if this is what you are looking for but this is how the Singleton Design Pattern works.
..:: Keno ::..
|
|
|
|