Hi everybody,
I currently use VB6 for database programming. I am in the process of switching over to VB.NET. I am substituting VB6 code with VB.NET code for some trial programs.
In VB6, I have made most of hierarchial recordsets using the SHAPE syntax of the SHAPE provider. E.g.
VB Code:
With rReport .CursorLocation = adUseClient .Open "SHAPE { SELECT stage FROM QEAF_Stage }" & _ " APPEND ( { SELECT * FROM QEAFs_Stages_Chances" & _ " WHERE [month] = #04/01/2004# }" & _ " RELATE stage TO stage ) AS EAFs_Stages_Chances", _ ConnShape, Options:=adCmdText End With
I have used the above code in a report. It requires only one round trip to the server to extract the data for the report.
To achieve the same thing in ADO.NET, a DataSet has to be created with two Data Tables in it and a Data Relation has to be created to relate the two tables. E.g.
VB Code:
Dim Conn As SqlConnection = New SqlConnection("Data Source=localhost;" & _ "Integrated Security=SSPI;Initial Catalog=EAF;") Dim StageDA As SqlDataAdapter = New SqlDataAdapter("SELECT stage FROM QEAF_Stage", Conn) Dim ChancesDA As SqlDataAdapter = New SqlDataAdapter("SELECT * FROM QEAFs_Stages_Chances WHERE [month] = #04/01/2004#", Conn) Conn.Open() Dim StageDS As DataSet = New DataSet("Stage") StageDA.Fill(StageDS, "QEAF_Stage") ChancesDA.Fill(StageDS, "QEAFs_Stages_Chances") Conn.Close() Dim Rel As DataRelation = StageDS.Relations.Add("StageChances", StageDS.Tables("QEAF_Stage").Columns("stage"), StageDS.Tables("QEAFs_Stages_Chances").Columns("stage"))
Now my question is, using this code, how many round trips to the server would be made to extract the data? Would all the data be extracted from the server to the Data Adapters in a single round trip on executing the command Conn.Open() ?




Reply With Quote