|
ok,can u please tell me how to loop trough the child tables in a dtaset.
dim r as datarow
for each r in ds.parent table..
like this how to read sub table of parent table in the dataset
|
|
|
|
|
foreach(DataTable table in ds.Tables)
foreach(DataRow row in table.Rows)
{
foreach(DataColumn column in table.Columns)
{
}
}
|
|
|
|
|
In the future please format any code snippets or xml like this, using the pre tags. What you have unreadable and will mostly get you ignored by those that can help the most.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
If the two datatables are in the same dataset, you can create datarelations
between them, and use the GetChildRows, GetParentRow methods to do something similar to joins.
I hope this helps.
Best,
Sanket Sirotiya
http://www.urchha.com/
|
|
|
|
|
Can u describe your question in more detail.
Like by giving example what exactly u want to do??
So, that we can help in better way.
Jinal Desai
|
|
|
|
|
Hi, thanks for ur support.The following is my xml.
I have two tables .videos and actors . I need the code to read and save the xml data as follows.
Videos table
titleID title director format
100 Gentleman Jonathan Lynn DVD
101 Her Alibi Bruce Beresford DVD
Actorstable
titleID Actor ActorID
100 Eddie Murphy M123
100 John J23
101 Eddie S623
xml file
<?xml version="1.0" encoding="utf-8"?>
<Videos>
<Video>
<ID>100</ID>
<Title>Gentleman</Title>
<Director>Jonathan Lynn</Director>
<Actors>
<Actor>Eddie Murphy</Actor>
<ActorID>M123</ActorID>
<Actor>John</Actor>
<ActorID>J23</ActorID>
</Actors>
<Format>DVD</Format>
</Video>
<Video>
<ID>101</ID>
<Title>Her Alibi</Title>
<Director>Bruce Beresford</Director>
<Actors>
<Actor>Eddie</Actor>
<ActorID>S623</ActorID>
</Actors>
<Format>DVD</Format>
</Video>
</Videos>
|
|
|
|
|
You can use datarelation in dataset,
relate your two tables that will reside in one
dataset.
And in that way you can manually access individual element from
datarelation and generate xml or you can use LINQ.
Hope this will help!
Jinal Desai - LIVE
|
|
|
|
|
Hi,
I have an xml file like the following. want to save the xml file either in one table or two tables. but i dont know how to link these two tables in the dataset.
Inorder to save the xml file into my database first import to dataset (dsSource.ReadXml(xmlfilename))and it comes in two tables in the dataset. how i can save this xml file into sql table.
xml file contains a main node student under that sub nodes are there
student -main node
name
id
place
Result-sub node
subject
mark
subject
mark
.....
result-sub node ending
student node end
Thanks in advance
|
|
|
|
|
Sorry - not quite sure whether you want to save the xml file itself into the table or parse it and then save the data into a table.
You can try out these links - here and here.
|
|
|
|
|
sorry, I want to save the data into my table. The dataset contains multiple tables I dont know how to link these tables.
|
|
|
|
|
My table structure is headerid,date,studid,studname,studsubject,studmark
i am working in vb.net.can you please help to save this to my table
<MAIN
<Header>
<ID>94</ID>
<TransactionDate>20/03/2010 16:10</TransactionDate>
</Header>
<STUDENT>
<ID>1076523</ID>
<NAME/>
<PLACE>101</PLACE>
<RESULT>
<SUBJECT>MATHS</SUBJECT>
<MARK>465.9</MARK>
</RESULT>
<RESULT>
<SUBJECT>Secondary</SUBJECT>
<MARK>272.4</MARK>
</RESULT>
</STUDENT>
<STUDENT>
<ID>AP1076524</ID>
<NAME/>
<PLACE>117-09-D000004-00</PLACE>
<RESULT>
<SUBJECT>Principal</SUBJECT>
<MARK>592.0</MARK>
</RESULT>
</STUDENT>
</MAIN>
|
|
|
|
|
I am a .net developer, and have worked on .net 2.0 or .net 3.5 for several years. I need to obtain the MCAD or MCPD for a new project. I will greatly appreciate if fellow members recommend some good books or practice-test materials so I can speed up the process.
Cheers,
-James
|
|
|
|
|
You "need" to obtain certification for the project?
MeasureUp are good practice exams. The Microsoft Press exam prep books are mostly worthless as far as I'm concerned.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
I am writing a dll class to take in health patient information. On the developer side, how do i initialize my structure variables?
'code in the dll
Public Class MyClass
Private someData as ArrayList = New ArrayList
Private Structure PatientData
Public myDate as Date
Public myDouble1 as Double
Public myDouble2 as Double
Public myDouble3 as Double
End Structure
Private Function AddData(ByVal visitdate As Date, ByVal bmi As Double, ByVal height As Double, ByVal weight As Double) As Integer
Dim visit As PatientData
visit.myDate = visitdate
visit.myDouble1 = bmi
visit.myDouble2 = height
visit.myDouble3 = weight
visitData.Add(visit)
End Function
end Class
'How do I populate these variables as the developer?
|
|
|
|
|
It seems like you're already doing it? What is the issue?
Also, please remember to format code you post using the pre tags, ie. code block
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
As it's a structure, they will automatically be initialized to their default values.
DaveIf this helped, please vote & accept answer!
Binging is like googling, it just feels dirtier. (Pete O'Hanlon)
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
|
|
|
|
|
bassmaster_general wrote: am writing a dll class to take in health patient information. On the developer side, how do i initialize my structure variables?
'code in the dll
Public Class MyClass
Private someData as ArrayList = New ArrayList
Private Structure PatientData
Public myDate as Date
Public myDouble1 as Double
Public myDouble2 as Double
Public myDouble3 as Double
End Structure
Private Function AddData(ByVal visitdate As Date, ByVal bmi As Double, ByVal height As Double, ByVal weight As Double) As Integer
Dim visit As PatientData
visit.myDate = visitdate
visit.myDouble1 = bmi
visit.myDouble2 = height
visit.myDouble3 = weight
visitData.Add(visit)
End Function end Class
'How do I populate these variables as the developer?
I don't think I was clear. I created a new class, new namespace etc. and was trying to test the interface from another form. I created an object of myClass and the function AddData was not appearing in "intellisense" as an option.
It is because my AddData function was declared as private in myClass. so the issue is resolved.
on another note, after changing the function from private to public, intellisense was still not displaying the AddData option.
I had to close Visual studio and reopen. Now the AddData option appears in the intellisense menu.
odd, thanks for the replies
|
|
|
|
|
I suggest you read up on access modifiers, such as private .
|
|
|
|
|
A few suggestions:
Generally speaking, classes should be used rather than structures. As reference types, classes use memory more efficiently, which is important if objects are going to be persisted for any length of time.
Putting your data class/structure outside the class will make it accessable to other parts of your code. If you flag it as Friend , it will be available in your module but not be exposed to users of your library.
Using the Property syntax will self-document that a variable is actually a property, allow you to have different scopes for getting and setting the property and do pre- and post-processing when you set the values such as raise events, change control visibility and so on. Even if you do not need this functionality now, there is no harm in building your code to be easily extensible.
You can avoid several problems by using a strongly typed enumerable like List(Of T) rather than generic enumerables like ArrayList . Another advantage is that the enumerable can be exposed as a read-only property, which lets you use its Add method instead of having to write your own.
Note also that MyClass is a keyword in VB.Net.
I would have written something like this:
Friend Class PatientData
Private _myDate As Date
Private _myDouble1 As Double
Private _myDouble2 As Double
Private _myDouble3 As Double
Public Property MyDate() As Date
Get
Return _myDate
End Get
Set(ByVal value As Date)
_myDate = value
End Set
End Property
Public Sub New(ByVal VisitDate As Date, ByVal BMI As Double, _
ByVal Height As Double, ByVal Weight As Double)
_myDate = VisitDate
_myDouble1 = BMI
_myDouble2 = Height
_myDouble3 = Weight
End Sub
End Class
Public Class OtherClass
Private _visitData As List(Of PatientData)
Friend ReadOnly Property VisitData() As List(Of PatientData)
Get
If _visitData Is Nothing Then _visitData = New List(Of PatientData)
Return _visitData
End Get
End Property
End Class
The Friend scope on PatientData means that the class can be used within your project but not outside it. That the properties of PatientData are Public makes no difference, as the more restrictive Friend will hide the whole class. You might want to set the class to Public but code the properties to Friend Set : the class will be available with read-only properties outside of your project but have read and write properties within. You could also flag the constructor with Friend , which will let you use existing instances of PatientData outside of your project but not create new ones.
Now, you can add a new visit to your list like this:
OtherClassInstance.VisitData.Add(New PatientData(visitDate, bmi, height, weight))
|
|
|
|
|
I am working on a program that will access an Access database. I am using VB.net 2003. My program in part will record the landings of commercially caught fish. I have structured the database with species names as the column heading and then the rows would be a record of each delivery. A fisherman could make around 50 deliveries in one year.
I have in excess of thirty species in this table as column headings. When I use the DataGrid object, the default is to present my database as it is created with speices names as columns headings. Is there a way to switch the rows and columns when it is being displayed in the program, so the species names become the row headings and the data are shown to the right as a column of data?
|
|
|
|
|
If you manually populate the DataGridView, you can put things anywhere you like.
As a side comment, are you sure you really want the species as columns? That sounds like an open invitation for problems down the line! I'd consider using some other record layout, like perhaps a species name and a record of delivery on each record. Better yet, normalize it and have a table with species name and an integer, then store the integer to indicate the species on the delivery record. That way you can add species, change their names, add other characteristics, etc.
But you know more about the application than I do, so maybe that wouldn't work.
Good luck!
CQ de W5ALT
Walt Fair, Jr., P. E.
Comport Computing
Specializing in Technical Engineering Software
|
|
|
|
|
Two things spring to mind initially. One, why not use a real database, SQL Express is free and far superior to Access, and two, usng the species as a column name means every time you need to add a new species you have to alter your table. Put the species in one table and the record of catches in another - probably there ought to be a further table with the fisherman details too. Get a book on database design before going any further, as using your current design is asking for trouble in the future.
In answer to your question, you can manipulate the data within your code to do what you want, but if you use SQL Express 2008 it can be done by using the PIVOT command.
Bob
Ashfield Consultants Ltd
|
|
|
|
|
Ashfield
I want to thank you and Walt Fair for the response. You both mentioned SQL Express and I will look into it. I do not do a lot of this sort of work, that is why I am still using vb.net 2003. I used an Access database because that it what I had handy, but I am early enough in this project that I can switch easily.
As far as the species names as column headings. I understand your point, but for good or bad, the fishery that this program is to used in is one that is managed by the Federal Governemnt and has a management plan that identifies exactly the species involved, so adding new species will not be an issue.
|
|
|
|
|
Hi Peter,
I believe you get SQL Express for free with Visual Studio 2005 as part of the VS 2005 installation. With 2003, you will have to download it and install it. I would suggest upgrading.
Glenn
|
|
|
|
|
Peter Leipzig wrote: As far as the species names as column headings. I understand your point, but for good or bad, the fishery that this program is to used in is one that is managed by the Federal Governemnt and has a management plan that identifies exactly the species involved, so adding new species will not be an issue.
Even so, you should bear in mind that this is a bad design which, although it may not cause you problems in this instance should really not be used - better to do it right every time rather than taking shortcuts which can soon lead to general sloppiness.
Bob
Ashfield Consultants Ltd
|
|
|
|