|
It will be kind of difficult using the schema you have defined. Where are your foreign keys (FKs)? The full join should look something like this (assuming proper FK development):
SELECT *
FROM Artists
INNER JOIN Albums ON (Artists.ArtistId = Albums.ArtistId)
INNER JOIN Tracks ON (Albums.AlbumId = Tracks.AlbumId)
INNER JOIN Files ON (Tracks.TrackId = Files.TrackId)
The type of joins you need to develop will depend on how you want the data displayed.
|
|
|
|
|
Thanks for the reply Michael.
I know how to do the JOIN in sql, that's not the problem. The problem is that from a design point of view each table is a separate C# class upon which I call the CRUD methods (album.Delete(), album.SelectOne() etc). What I need to know is what is the best way of joining the tables under this scenario?
I've been think of defining views for each JOIN which I require and then generating classes for each of those but I'm not convinced it is the best way to go about it.
Cheers
James
|
|
|
|
|
Hi,
I have developed a plugin for Excel that i need to test. I need to simulate the user entering a lot of data into the sheet and was wondering if there was an app./plugin out there that does that.
Any help is appreciated.
Thanks.
|
|
|
|
|
I need to load a datagrid on a tabpage then if a user moves form tab to tab i want to retain the values they may have added but as there is no Load event for a tabpage im stuck, the enter event is no good as it would reset the datagrid values back to defauls? So when the tabpage loads i want to display default values, then if the user alters them and move yto another page and back again the values remain. No update to the database have been executed.
|
|
|
|
|
The TabControl which contains the TabPages has an event SelectedIndexChanged , it is called before the next TabPage is shown. You can use it instead of a TabPage.Load event.
|
|
|
|
|
that would still cause the values to reset?
|
|
|
|
|
I am applying 2 different grid styles to the same datagrid. When I apply first style to the grid it gets applied to the grid, but when i apply the second style, it does not get applied. I am clearing the grid style before applying the new style.
datagrid1.TableStyles.Clear();
Can anybody tell me what is the reason for this and what is that I am missing??
Thanks in advance.
|
|
|
|
|
If the DataGridTableStyle.MappingName is different for both (and it must match up with the data source, such as a DataTable , array, or an IList implementation's class name), then you don't need to clear them. That's why the DataGrid.TableStyles property is a collection property. So long as the styles handle different data sources, it's not a problem to keep both in there. In fact, I'm pretty sure you're using different MappingName s since the Add method checks for duplicates and throws an exception in such a case. Just keep both styles in the collection.
When you're applying a style, you must re-bind the data source. The data source is "stylized" during binding.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I have an XML file with which has elements and each element has one or more attribute. I can read the element fine, but I am no able to read each attribute separately as my attributes are defined like..
<name fname="xxxx" lnem="uuuu">
<job>dddd</job>
....etc
</name>
I cannot read fname & lname separately.
Please help.
|
|
|
|
|
Here is a good article about XML parsing in C#
http://www.windevnet.com/documents/s=8692/win0307b/0307b.htm
xedom developers team
|
|
|
|
|
But a registration form comes up there. I can't open the page.
MaXx
|
|
|
|
|
How are you reading in the XML file? If you use an XmlTextReader , for example, there is plenty of ways to access both elements and attributes, as well as processing instructions, comments, etc. If you're using an XmlDocument along with the rest of the XML DOM classes, then there are ways to access attributes, elements, processing insturctions, etc., as well. Read the documentation for the class(es) you're using in the .NET Framework SDK.
Otherwise, please be more specific about why you can't seem to read attributes and maybe we can help.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Yes I am using the XmlTextReader. I have a file like
<?xml version="1.0" ?>
<!-- This file represents a fragment of a book store inventory database
-->
<bookstore>
<book genre="autobiography" publicationdate="1981" ISBN="1-861003-11-0">
<title>The Autobiography of Benjamin Franklin</title>
<author size="25">
<first-name age="25">Benjamin</first-name>
<last-name>Franklin</last-name>
</author>
<price>8.99</price>
</book>
<book genre="novel" publicationdate="1967" ISBN="0-201-63361-2">
<title>The Confidence Man</title>
<author>
<first-name>Herman</first-name>
<last-name>Melville</last-name>
</author>
<price>11.99</price>
</book>
<book genre="philosophy" publicationdate="1991" ISBN="1-861001-57-6">
<title>The Gorgias</title>
<author>
<name>Plato</name>
</author>
<price>9.99</price>
</book>
</bookstore>
I am using the ReadString funcyion to read attributes like
...
book genre philosophy publicastiondate 1991 etc.. but.. I can read only one string.. like only philosophy, not the reat..
I want to read each of the attributes saparately.
HELP
MaXx
|
|
|
|
|
You should be using XML-specific methods, like GetAttribute , MoveToAttribute , or ReadAttributeValue . The idea about the XmlTextReader is forward-only reading. You move from element to element and attribute to attribute. If you treat everything as a string, of course you will not get what you want; you may as well not even use XML if you treat the document as a simple text file.
You really should read about the class members on the XmlTextReader [^].
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I got this code on the net....
private void AddWithChildren(XmlNode xnod, Int32 intLevel)
{
//Adds a node to the ListBox, togather with its children.
//intLevel controls the depth of indenting
XmlNode xnodWorking;
String strIndent = new string(' ',2 * intLevel);
//Get the value of the node (if any)
string strValue = (string) xnod.Value;
if(strValue != null)
{
strValue = " : " + strValue;
}
//Add the node details to the ListBox
Console.WriteLine(strIndent + xnod.Name + strValue);
//For an element node, retrive the attributes
if (xnod.NodeType == XmlNodeType.Element)
{
XmlNamedNodeMap mapAttributes = xnod.Attributes;
//Add the attributes to the ListBox
foreach(XmlNode xnodAttribute in mapAttributes)
{
Console.WriteLine(strIndent + " " + xnodAttribute.Name +
" : " + xnodAttribute.Value);
}
//If there are any child node, call this procedrue recursively
if(xnod.HasChildNodes)
{
xnodWorking = xnod.FirstChild;
while (xnodWorking != null)
{
AddWithChildren(xnodWorking, intLevel +1);
xnodWorking = xnodWorking.NextSibling;
}
}
}
It workes fine but I thought it would be a little easier to get the attributes.. mainly those which are present in the same line as the element tag like
<person fname=nnn lname=hhh>
.....
</person>
Is there an easier way...
MaXx
|
|
|
|
|
You don't read lines in XML, you move from element to element, and attribute to attribute.
Read the class documentation for the XmlTextReader in the .NET Framework SDK. There are plenty of examples there as well. It is very easy, but you don't treat XML as a plain text file, i.e. you don't read lines.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
ok.. maybe i'll find an easier one..
thanx for everythin' bro..
MaXx
|
|
|
|
|
There is no easier way, man! Seriously, read the documentation for classes in the System.Xml namespace in the .NET Framework SDK. XML is easy to work with, one reason it's so popular. There's lots of examples in that documentation, like for the XmlTextReader that you'll probably want.
There's two ways of reading XML: parsing the DOM or parsing the document itself (SAX; basically). You could load an XML document completely into memory using the XmlDocument and use XPath (via SelectNodes or an XPathNavigator , which is pretty fast) to get what you need. This is good for smaller documents.
For larger documents you don't want to load the whole thing into memory, so you use SAX, which is an event-driven way to parse the document. This isn't exactly what using an XmlTextReader is, but it is a forward-only way of reading XML documents. While it isn't event driven, it is operation driven (basically the converse of SAX).
So, if you're document is small and you want to extract, for example, the language that is the default language, do something like this:
XML Document-----------------------------------------------------------
<languages>
<language default="true">
<name>en-US</name>
<englishName>English (United States)</englishName>
</language>
<language>
<name>de-DE</name>
<englishName>German (Germany)</englishName>
</language>
</languages>
C# Snippet-------------------------------------------------------------------
XmlDocument doc = new XmlDocument();
doc.Load("languages.xml");
XmlNode node = doc.DocumentElement.SelectSingleNode(
"language[@default = 'true']/name");
if (node != null)
return CultureInfo(node.Value);
else return null;
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I think I'll use the XmlTextreader. I can navigate throught the nodes properly with the function I have (given up there^) but do I have to use a level variable to go to each attribute and next, Isn't there an attribute reader?? which can go without bieng followed? (by level)
MaXx
|
|
|
|
|
See the XmlTextReader.MoveToNextAttribute , which should stick out like a sore thumb if you read the class documentation for XmlTextReader . There's simply no reason not to read the class documentation, especially for those classes you use in your code.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
of course I read the documentation, I also did the .. readstring.. thing looking at the documentation..
Believe! Every thing has a purpose
|
|
|
|
|
watvh this movie[^]
watch the reading xml files one, it shows how to read attributes. it is in vb, but its in simple code, so it should be easy to convert.
/\ |_ E X E GG
|
|
|
|
|
Thanx for the link eggie, but I cannot cache the win media 9 videos, I have a pretty slow Internet speed, & I can't connect each time I have to view them.
But anyways... that reading Xml files video was good. thanx
MaXx
|
|
|
|
|
Hi,
I want to do some file transfer using FTP. I couldn't find any FTP Class in C#. Is C# is having a class for supporting ftp.
Regards,
Satya
|
|
|
|
|
Hi,
I'd like to have an Assembly running on MachineA which can be accessed (it's classes instanciated) from MachineB. The point is, I'd like to create a Database layer which can be accessed from various client machines and from the webserver. Therefore my plan for such a distributet environment.
What I need is some reading, keywords, starting points. Lot's of thanks in advance.
Matthias
If eell I ,nust draw to your atenttion to het fakt that I can splel perfrectly well - i;ts my typeying that sukcs.
(Lounge/David Wulff)
www.emvoid.de
|
|
|
|