Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

HOW do I bind two tables to a datagrid???

Status
Not open for further replies.

mongous

Technical User
Jun 18, 2002
116
US
I have a data adapter that pulls two different tables from an Access database:

1. RepData - contains statistical info on cust serv reps
2. Agents - contains names linked by Logid field

If I right click on the Data Adapter and choose 'Preview Data' I can see the appropriate data with the exception of the date ranges (entered by user).

But I cannot get the datagrid to show that info. I have it selecting the right data, if I just pull from the 'RepData' table (thus showing data with LogId).

Once I try to link the 'Agents' table to show names, I get nothing.

Code:
Me.OleDbSelectCommand2.CommandText = "SELECT tblAgents.FirstName, tblAgents.LastName, tblRepData.Logid, tblRepData.Calls, tblRepData.Staffhours, tblRepData.Row_Date, tblRepData.Team, tblAgents.EmpId FROM (tblAgents INNER JOIN tblRepData ON tblAgents.LogId = tblRepData.Logid)"
Me.OleDbSelectCommand2.Connection = Me.cnRrpData

Then of course that is appended when the user makes their Team/Date range choices:
Code:
   Private Sub btnSubmit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSubmit.Click

        daAgents.SelectCommand.CommandText = daAgents.SelectCommand.CommandText & " Where (tblRepData.Team = '" & lstTeams.SelectedValue.ToString & "') and (Row_Date BETWEEN #" & StartDate.Text & "# and #" & EndDate.Text & "#)"

        daAgents.Fill(DsAgents)
        dgTeamInfo.DataBind()
    End Sub

Can anyone point me in the right direction? Any help appreciated!
 
mon: doesn't strike me as anything in particular w.r.t. dot NET performance - if the SQL is successful the binding should proceed w/o exception. Just a thought, you might want to post your code over at the SQL Forum; they may be able to spot something wrong with the syntax right away --
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top