TheSwamp
Code Red => .NET => Topic started by: Kerry on November 19, 2007, 06:53:05 AM
-
Had a play tonight ..
DrivePath added:
Save as C:\ProjectStart.XML
<?xml version="1.0" encoding="utf-8" ?>
<ProjectList>
<LastProject>J1002</LastProject>
<Project>
<ProjectID>1001</ProjectID>
<ProjectNumber>J1001</ProjectNumber>
<ProjectName>ALPHA</ProjectName>
<ClientName>Us and Them</ClientName>
<JobServer> \\\\Screamer\Drive D\TestProjects</JobServer>
<JobSubstDrive>W:</JobSubstDrive>
<JobFolder> \J1001</JobFolder>
<TSDFolder>\TSD</TSDFolder>
<StdConsSubstDrive>V:</StdConsSubstDrive>
<StdConsFolder>\V-Drive\V-Std</StdConsFolder>
</Project>
<Project>
<ProjectID>1002</ProjectID>
<ProjectNumber>J1002</ProjectNumber>
<ProjectName>BRAVO</ProjectName>
<ClientName>Them and Co.</ClientName>
<JobSubstDrive>W:</JobSubstDrive>
<JobServer> \\\\Screamer\Drive D\TestProjects</JobServer>
<JobFolder> \J1002</JobFolder>
<TSDFolder>\TSD</TSDFolder>
<StdConsSubstDrive>V:</StdConsSubstDrive>
<StdConsFolder>\V-Drive\V-Std</StdConsFolder>
</Project>
<Project>
<ProjectID>1003</ProjectID>
<ProjectNumber>J1003</ProjectNumber>
<ProjectName>CHARLIE</ProjectName>
<ClientName>Bloggs and Assoc</ClientName>
<JobSubstDrive>W:</JobSubstDrive>
<JobServer> \\\\Screamer\Drive D\TestProjects</JobServer>
<JobFolder> \J1003</JobFolder>
<TSDFolder>\TSD</TSDFolder>
<StdConsSubstDrive>V:</StdConsSubstDrive>
<StdConsFolder>\V-Drive\V-Std</StdConsFolder>
</Project>
</ProjectList>
Then run this ..
Note the projectNumbers are J1001, J1002, J1003 ..
using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
//----------------------------------------------
// CodeHimBelonga kwb: 2007/11/19 21:40:04
//----------------------------------------------
namespace XML_ConsoleApplication_001
{
class Program
{
static void Main(string[] args)
{
DataSet dsProjects = new DataSet();
dsProjects.ReadXml(@"c:\ProjectStart.XML");
DataView dvProject = new
DataView(dsProjects.Tables["Project"]);
dvProject.Sort = "ProjectNumber";
Console.Write("\nEnter Project Number :");
string input = Console.ReadLine();
int rowIndex = dvProject.Find(input);
if (rowIndex == -1)
{
// The ProjectNumber was not found in our data
Console.WriteLine("\nProjectNumber {0} was not found.", input);
Console.ReadKey();
return;
}
//else proceed
string ProjectID = dvProject[rowIndex]["ProjectID"].ToString();
string ProjectNumber = dvProject[rowIndex]["ProjectNumber"].ToString();
string ProjectName = dvProject[rowIndex]["ProjectName"].ToString();
string ClientName = dvProject[rowIndex]["ClientName"].ToString();
string JobServer = dvProject[rowIndex]["JobServer"].ToString();
string JobSubstDrive = dvProject[rowIndex]["JobSubstDrive"].ToString();
string JobFolder = dvProject[rowIndex]["JobFolder"].ToString();
//
Console.WriteLine("\nProjectID {0}"+
"\nProjectNumber : {1}"+
"\nProjectName : {2}"+
"\nClientName : {3}"+
"\nJobServer : {4}"+
"\nJobSubstDrive : {5}"+
"\nJobFolder : {6}",
rowIndex.ToString(),
ProjectNumber,
ProjectName,
ClientName,
JobServer,
JobSubstDrive,
JobFolder
);
//
Console.Write("\nPress any key to proceed.");
Console.ReadKey();
}
}
}
Note, this is not meant to be in the least indicative of good code .. just posting what i'm learning :-)
.. and the obligatory piccy,
-
Cool.
I can learn from this. Thank you Kerry.
-
Very cool Kerry!
-
John, David ;
yep, this is fun ..
and you're most welcome.
-
That looks easy enough Kerry, very clean example and a very good starting point.
Gotta love text based documents :)
-
Wheeeee .. in VS2008 Linq in Xml has some potential.
Time to hit the books I think .. :-)
-
I'm wetting myself ..
[/too much information]
A piccy is enough !
-
I'm wetting myself ..
Well, off to buy cleaning supplies :lol:
-
I'm really going to enjoy this Dan ..
-
This looks like something we were discussing not so long ago Kerry...good to see you're making progress with it.
Cheers,
Glenn.
-
This looks like something we were discussing not so long ago Kerry...good to see you're making progress with it.
Cheers,
Glenn.
Hi Glenn,
yep, this is the start of the beast.
Has your body clock adjusted to Greenwich Mean Time yet ?
-
WOW, .. no way for me to bookmark this topic so I guess I'll reply so I can find it again later.
Thanks for the SAMPLE
-
The beauty of DataSets is their ability to:
1) Hold a collection of DataTables
2) Read and Write XML data.
3) The ability to connect them to a DataGridView
I am in the process of working on a BOM program using all 3 features listed above. The nicest feature is I can write the DataSets XML to an XRecord in the drawing, which then can be loaded every time my BOM program is initiated.
I can provide code if needed when I get back on my windows laptop but unfortunately for most I do all my coding in BOO so SharpDevelop's translator would be needed.
-
Has your body clock adjusted to Greenwich Mean Time yet ?
Yep - all's good Kerry. Will speak to you soon.
Cheers,
Glenn.