
How to execute a Inner Join between Tables on a DATASET
Thanks Kamal,
I had believed that inner joins in dataset would be possible because it
makes sense, the dataset have primary keys, foreign keys and relations and
it only to use existing features.
To solve my problem i use the iteration to the datarow collection witch is
more slowly and with more code, to simply insert a dataset table in an
access database and test if the new row already exists in the table of the
target database.
Is there a simply Way?
The Code goes Here:
Dim Erow As DataRow
Dim e1Row As DataRow
Dim Etable As DataTable
Dim E1table As DataTable
AccAdDocDestino.Fill(dsAccess, "DocDestino")
Dim sqlCmd2 As OleDbCommand
Dim dcd As String
Dim dcDes As String
Dim TrueTable As Boolean
For Each e1Row In ds.Tables("DocDestino").Rows
TrueTable = False
For Each Erow In dsAccess.Tables("DocDestino").Rows
If e1Row("DocDestino") = Erow("DocDestino") Then
MessageBox.Show("DBAccess:" &
Erow("DocDestino").ToString & vbTab & vbTab)
Else
TrueTable = True
dcd = Erow("DocDestino").Column("Docdestino")
dcdes = Erow("DocDestino").Column("Docdestino")
End If
Next
If TrueTable = True Then
sqlCmd2 = New OleDbCommand("insert into DocDestino
(Docdestino,DocDestDescr) Values ('" & dcd & "','" & dcDes & "')",
AccessCon)
sqlCmd2.ExecuteNonQuery()
End If
Next
Thanks in Advance,
Joviano Silva
Quote:
> Hi Joviano,
> Running queries on tables of a disconnected DataSet are not supported by
> ADO.NET. You would have to iterate through the existing tables and add
data
> to your new table.
> If you plan to run a lot of queries on tables of a disconnected
DataSet(s),
> you might want to consider storing data on the client side in a small
> database such as access or fox which provide OleDb access.
> hth,
> Kamal
> --------------------------------------------------
> Kamal Patel
> http://www.KamalPatel.net
> --------------------------------------------------
> > Hi All,
> > Somebody knows how to run a Query with inner joins between tables of a
> > disconnected Dataset?
> > Usually after creating a Dataset with relations and Keys from the Data
> > Adapter witch connects to the Database we close the DataAdapter and work
> > only with the Dataset, so we need to work with the inner join between
> tables
> > of a Dataset.
> > The Sql command need a connection to the database, what is the best way
to
> > execute Queries to Tables in a Dataset without requiring the connection
to
> > the Database?
> > Thanks in Advance,
> > Joviano Silva