|
Hello,
I am trying to understand the basics of XML, and I have a very simple idea which doesn't seems to be so simple I used INI files before and decided it was time to try XML. But I didn't came further than
Dim xmldoc As New XML.XMLDocument
I have the following INI file which I want to store in a XML file:
[Settings]
WindowState=0
etc..
Can someone show me how to store this in a XML file?
I am using VB.NET and Visual Studio 2005.
Thanks,
--Zaegra--
|
|
|
|
|
One obvious example would be
<Settings>
<WindowState>0</WindowState>
</Settings>
I suggest you read up on what XML is, and how it works. You'll need to read up on XPath to be able to find your settings within this file, too.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
I know the structure of an XML file, but I'd like to know how i can store these values in an XML file in the proper way. Could you tell me how to accomplish this? I searched CodeProject but i didn't really find what i needed
|
|
|
|
|
If I am using an XML source I use a dataset to manage the data in the app and read/write it using the dataset.readxml methods. This really is a nobrainer if all you want is to manage the data via xml. If you want to do any more then as Christian suggested you will need to devote some study time to it.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Mycroft Holmes wrote: This really is a nobrainer
Well, everybody needs to start somewhere, doesn't he . But thanks for the reply, I'll try it.
--Zaegra--
|
|
|
|
|
Zaegra - I did not want to imply nobrainer was personal. Dataset to and from XML really is simple to use but it will not give you ANY insight into using XML.
And yep we ALL started somewhere, I have almost no working knowledge of XML as I rarely use it.
However I have 1 strong caveat, do NOT use XML for transporting large volumes of data, XML is so verbose your data size will may become an issue. Use CSV instead.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
The 'proper' way really doesn't exist, XML is a loose format, you can structure it any way you like.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Another method of handling this is with XMLSerializer, you use it to persist classes in XML. So you could have an INI object that you fill with data and then serialize it to disk, then when you want the data back you just de-serialize it. It is pretty simple have a look on msdn for code samples.
This way you can have a class that has the property WindowState, you then set this property in an instance of the class to 0 (obj.WindowState = 0) then serialize the object (something like serializer.Serialize(obj, path))
then just reverse this to fill the class and read its properties like any other class.
Hope that's of some use.
At university studying Software Engineering - if i say this line to girls i find they won't talk to me
Dan
|
|
|
|
|
Hi
I’ve started to develop VB.Net application within the company I work for using Visual Basic 2008 Express Edition.
Working and testing locally I had no problem, but when I started to develop the application on my shared mapped drive I started get problems.
The first one was, when I loaded the project from the mapped drive a popup message stating:
“The Project location is not trusted
[PATH]
running the application may result in security exceptions when it attempts to perform action which require full trust”
I’ve been into the project security properties and set it to “this is a full trust application” and still not joy.
If I develop and build the application on my local machine and then try and run it on a mapped drive it fall over and crashes (Doesn’t even seem to start).
Does anyone have any ideas on how I can get around this?
Thanks
|
|
|
|
|
cooper000007 wrote: Does anyone have any ideas on how I can get around this?
Network locations are not trusted by default in .NET. Only the local physical machine is trusted by default.
You have two solutions.
1. Tell .NET to trust the network location.
2. Strong name the assemblies and tell .NET to trust those assemblies.
The advantages of 1 are that you don't have to change the way you develop the assemblies, however it becomes a hassle if you have to change the network location - especially if you are running it on many machines (they all have to be updated)
The advantages of 2 are that you only have to tell each machine once and it will trust any assembly that has been signed with the strong name key. This means you can sign multiple assemblies and they can be run from any network connection. However, it means you will have to be careful with the key. If it gets in to the hands of someone malicious then they can use it to create assemblies that your machines will trust.
In order to tell each machine about which ever of the above routes you want to take you have to use the Microsoft .NET Framework x.x Configuration tool found in Administrative Tools.
|
|
|
|
|
Hi all
I have been working on a piece of GIS software with my team for a little over 12 months now. We have now made it to the Microsoft Imagine Cup World Finals and are seeking to improve certain areas of our program. One of which is to improve the method we use to calculate the remaining trip time of a vehicle on a predefined route, at any point in its route. Can anyone please provide an algorithm we can use or some source where we can learn to build a more efficient algorithm. Time is short, but this is a very necessary improvement. Thanks in advance for any help.
Kind regards.
Dev
|
|
|
|
|
To calculate the remaining travel time, you need to know the speed of the vehicle. Then you can use the formula t=x/v. T = Time, X = Distance, V = Speed. You could subtract the number of ridden meters of the total. Then divide that by the speed in meters per second (m/s) and you have the remaining time in seconds.
Good luck!
--Zaegra--
|
|
|
|
|
Yes, this is correct and provides a very elementary estimate, but an algorithm is required which allows for environmental factors to be added to the estimate.
|
|
|
|
|
There are a lot of formulas to calculate the friction. I am not that good in physics (basically that's what this is) but I do know the following formulas which might come handy.
- F (Force in Newton) = M (Mass in Kilograms) * A (Acceleration in M/s²)
- W (Energy in Joule) = F * s (Distance in Meters)
- A = V (Speed in M/s) / T (Time in Seconds)
- X (Distance in Meters) = V * t
- Ekin (Kinetic Energy in Joule) = 0.5mv²
Since you know the route, it's possible but VERY slow to calculate the friction on eg bumpy parts of the road. You can implement that in your program as a constant or whatsoever. Try Google aswell.
|
|
|
|
|
i am working in vb.net 2005, in my DAL there is always a new connection but in the finally of each function i always close the data reader object,does it make any problem because i think connection remains open , doest it increase the number of connections ?
hello
|
|
|
|
|
You should close the connection, but .NET manages a connection pool, I believe.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Yes, the connection definitely remains open unless you specifically close it (either by calling the Close or Dispose method of the connection).
If you don't close the connection, it will remain open until it makes a timeout, which happens after a few minutes. If too many connections remain open, the database will not allow any more connections, so it will effectively stop working until the next connection makes a timeout.
An Access database has a limit of 64 connections, so it will die rather quickly. Database servers have a higher limit, but it's still there.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
as what every one has told already... you need to close the connection
There is just one small information which i will like to add..
Unlike the "recordset" in VB6, the result from DB is stored in the datareader in VB.net.
If you are using a common function to interact with DB, in that function only open the Connection and close it before you leave the function.
Regards
Nishkarsh
|
|
|
|
|
nishkarsh_k wrote: Unlike the "recordset" in VB6, the result from DB is stored in the datareader in VB.net.
Actually, as the name suggests, the DataReader is used to read the data rather than storing the data.
A DataReader is similar to a forward-only read-only Recordset.
A DataTable is similar to a disconnected Recordset.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
but i am using a central function to open and close the connection and it returns a data reader object , i can close the reader object whilst i am leaving the function but i cant close the connection coz i dont have that opened connection in this method .
any help ?
hello
|
|
|
|
|
In which case you need to refactor your code to allow it
Bob
Ashfield Consultants Ltd
|
|
|
|
|
i think you must close the connection,thus; if you didn't do that you may get deadlock
|
|
|
|
|
I am working in Visual Studio 2005, and am running a model that is meant to run through 500000 clients, and project things for them 25 years in the future.
In each years loop, different dll functions are called and values obtained.
The model runs though around 300000 clients succcessfully before crashing with the "OutOfMemoryException" message. Under numerous runs, it has been seen that no particular borrower, or no particlaur dll function is the source of the problem, but it always crashes on a dll funcion.
I have tried to clear memory by using GC.Collect(), but it has made no difference.
Is there anything I can be looking at to clear memory, help the programme run though?
Cheers
Juan Patrick
|
|
|
|
|
Does your memory usage steadily climb ? Look for objects you create which have a Dispose method, which you don't call. You should use using statements where-ever possible. It's possible a dll is what's leaking memory, from what you've said. in that case, GC.Collect will do nothing, but you should not have to call it anyhow, you should just make sure you manage your own memory,
Do you create any bitmaps or objects like that in your code ? They are a very likely culprit.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Hi Christian,
I can't remember what was happening with the memory usage, so will run model and check out again.
I was just reading up about the Dispose method when you sent this through (I haven't struck it before). Still a bit unclear on it at the moment. Where you have said "Look for objects you create which have a Dispose method, which you don't call," should I be calling the dispose method on these?
I don't create any bitmaps, but do have a number of objects - some are used as arrays - probably five, of which, two are repopulated every new client i.e. ideally 500000 times during the model. Should these be cleared (dispose) after each client, or can they simply be re-written over, which I assume i was doing? The only other reference to objects is simply as part of some other funcationality e.g.
For a button to quit the programme
Private Sub btnQuit_Click(ByVal sender As System.Object,...
Anyway, I will set the model running, and check it out for the memory.
|
|
|
|