473,473 Members | 1,823 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Value of 2 dataTable in a DataSet

Hi all, i'm newhere and I'm french so excuse me for my bad english :(
In my dataset I have 2 Table:
-the first named questionnaire which has 4 columns: question_Id,
ennonce, format and type
-the second, named answer which as 3 columns: code, answer, and
question_Id

My data come from an XML file.

I want to display answer which are linked to a question. And this for
all question

I hope you understand me!

Nov 20 '05 #1
3 1038
Hi Cortex,

One minute ago I did send this sample that I made just before, I changed it
a little bit here for you Tables are A and B can also be 0 and 1

Dim drlA As New DataRelation _
("AA", ds.Tables("A").Columns("A.question_Id"), _
ds.Tables("B").Columns("B.question_Id"))
ds.Relations.Add(drlA)
Dim dv As New DataView(ds.Tables("A"))
DataGrid1.DataSource = dv
DataGrid1.Expand(-1)

Do not excuse you for your English in this newsgroup, which is very
international with lot of regulars from the EU who are used at least to
understand more languages.

I hope this helps, and further question feel free to ask, however in Enlish.

Cor


Nov 20 '05 #2
thx for your help but:

-first: I have tryed to creta a datarelation like you but there is an
erro: "there is already a datarelation for these chiild columns"

-After: I don't want to use a datagrid: i use a loop (for each) which
build some html table

Otherwise i succed to make what i wante with this code:

iiQuestionId =
r(ds.Tables(0).Columns(0))
iiNum = iiQuestionId + 1
isEnnonce = r(ds.Tables(0).Columns(1))
isType = r(ds.Tables(0).Columns(2))

Response.write("<center><table><th>Question
" & iiNum & ": " & isEnnonce &
"</th>")
Response.write("<tr><td>")

for each r2 in ds.Tables(1).Rows 'on parcourt toutes les
lignes de la table reponse
If (r2(ds.Tables(1).Columns(3)) =
iiQuestionId) Then 'on affichque que les reponse portant le meme
Id que la reponse
if (r(ds.Tables(0).Columns(2)) =
"text") Then 'si le format de la question est text
alors on traite a part
isRepvalue = ""
isTypeFinal = "<input type='text'" &
"id='" & iiQuestionId & "' name='" &
iiQuestionId &"' size='25' runat='server'>"
Else
isRepValue = r2(ds.Tables(1).Columns(2))
isTypeFinal = "<input type='"& isType &
"'" & "id='" & iiQuestionId &
"' name='" & iiQuestionId &"'
runat='server'>"
End If
Response.write(isTypeFinal & " " &
isRepValue & "<br />")
End If
Next
Response.write("</td></tr></table></center><br
/>")
Next
But i think this isn't a good way, no?

Nov 20 '05 #3
Hi Cortex,

This I made once for someone who never used it.
It is for a windows application, however you get the idea and when you are
making aspx pages it should be easy enoug to translate it, when not, feel
free to ask.

I hope this helps?

Cor

Public Module main

Public Sub main()
'First the testtable
'Make a datatable with 8 columns
Dim ds As New DataSet
Dim dt As New DataTable("Cortex")
For i As Integer = 0 To 7
Dim dc As New DataColumn(Chr(i + 48))
dt.Columns.Add(dc)
Next
'And 12 rows every column filled with a letter
For i As Integer = 0 To 11
dt.Rows.Add(dt.NewRow)
For y As Integer = 0 To dt.Columns.Count - 1
dt.Rows(i)(y) = Chr(y + 65)
Next
Next
ds.Tables.Add(dt)

Dim Cortex As New ArrayList
For i As Integer = 0 To ds.Tables("Cortex").Rows.Count - 1
Dim row As New System.Text.StringBuilder
Cortex.Add(row)
row.Append("<TR><TD>")
For y As Integer = 0 To ds.Tables("Cortex").Columns.Count - 1
row.Append(ds.Tables("Cortex").Rows(i)(y).tostring )
If y <> ds.Tables("Cortex").Columns.Count - 1 Then
row.Append("</TD><TD>")
Else
row.Append("<TD></TR>")
End If
Next
Next
Dim sw As New IO.StreamWriter("C:\Cortex.html")
sw.WriteLine("<HTML><HEAD></HEAD><BODY><TABLE>")
For i As Integer = 0 To Scorpion.Count - 1
sw.WriteLine(Scorpion(i).ToString)
Next
sw.WriteLine("</TABLE></BODY></HTML>")
sw.Flush()
sw.Close()
End Sub
End Module
Nov 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Woody Splawn | last post by:
Lets say I have a winform that is populated with a dataset. The dataset and data table may have several rows in it. Lets say I am looking at the winform and I want to assign a value to a certain...
3
by: Jon | last post by:
I'm learning about datatables. When using the example provided by MS in the ..NET Framework Class Library for DATATABLE (see below) I get an error on line 3 that says "Type expected". Is something...
2
by: eBob.com | last post by:
I've got the basics of an XML ini file working. I.E. I can stash away and retrieve user preferences. (Code below.) But how do I handle a new preference? Say I have A and B. And then I invent...
7
by: Simon Verona | last post by:
I posted this in dotnet.languages.vb.controls but thought I'd post here as well.. I have a combobox that is bound to a dataview generated from a dataset. The dataset has a single table...
7
by: Peter | last post by:
Gday, I have a dataset with multiple tables, from which I want to access a single value in one of those tables. I know I can do something like: Decimal myVar =...
9
by: PeterWellington | last post by:
I have a column in a data table that stores enum values and assigns a default value: Dim dc As New DataColumn("TestEnumField", GetType(DayOfWeek)) dc.DefaultValue = DayOfWeek.Thursday When I...
10
by: dauphian | last post by:
Hello, I am new to .net and am trying to build a report application that queries 4 different tables based on a id, and I need to return them in the same table for easy viewing. Basically, I...
0
by: Maart_newbie | last post by:
Hi all, I've got a question about returning the value of a pk-column to a DataTable after inserting a row (via a data-adapter) using MySql5. Here is the SQL and code concerned: ...
3
by: =?Utf-8?B?UmljaCBIdXRjaGlucw==?= | last post by:
I'm not really sure how to ask this question because I'm still getting my feet wet with data access and VB.NET, but here goes: To start off with, I'm using VB 2005 Express to connect to an Access...
2
by: =?Utf-8?B?Um9oaXQ=?= | last post by:
I need to pass a DataTable object by value over a tcp socket. Unfortunately, I am forced to use the .NET framework ver. 1.1 for reasons that I don't want to get into. Does anybody know how I can...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.