problem with code for dataset with mutilple tables

C

Cindy H

Hi

I'm not getting any data back on this code.

Can someone tell me what I'm doing wrong?

What I really want is to select fields out of two table where the display
= 'y' from both tables and in one table the email is = to variable I'm
passing.

Public Shared Function GetSelectedProgressReport(ByVal Email As String) As
DataSet

Dim dsCustProg As New DataSet

Dim cmdCustProg As New OleDbCommand

Dim cSelect As String = "SELECT * FROM ConstructionCustomers WHERE Display =
'y' and Email = @Email"

Dim pSelect As String = "SELECT * FROM ConstructionProgress WHERE Display =
'y'"

cmdCustProg.CommandText = cSelect

cmdCustProg.CommandText = pSelect

' Add Parameters to cmd

Dim parameterEmail As OleDbParameter = New OleDbParameter("@Email",
OleDbType.VarChar, 100)

parameterEmail.Value = Email

cmdCustProg.Parameters.Add(parameterEmail)

cmdCustProg.Connection = MyConnection()

Dim daCustomer As New OleDbDataAdapter

Dim daProgress As New OleDbDataAdapter

daCustomer.SelectCommand = cmdCustProg

daProgress.SelectCommand = cmdCustProg

daCustomer.Fill(dsCustProg, "ConstructionCustomers")

daProgress.Fill(dsCustProg, "ConstructionProgress")

Dim relation As DataRelation = _

dsCustProg.Relations.Add("CustProg", _

dsCustProg.Tables("ConstructionCustomers").Columns("CustomerID"), _

dsCustProg.Tables("ConstructionProgress").Columns("CustomerID"))

Return dsCustProg

End Function

Thanks,

CindyH
 
C

Cor Ligthert [MVP]

Cindy

Both adapters needs there own commands.
(The commandtext is no collection so you are now just overwriting it)

You can use the constructer by this by the way, which is much easier

Dim da as new OledbDataAdapter(SelectString, connection)

I hope this helps,

Cor
 
C

Cindy H

Thanks, will give her a try.




Cor Ligthert said:
Cindy

Both adapters needs there own commands.
(The commandtext is no collection so you are now just overwriting it)

You can use the constructer by this by the way, which is much easier

Dim da as new OledbDataAdapter(SelectString, connection)

I hope this helps,

Cor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top