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!

Need help binding two tables to a datagrid

Status
Not open for further replies.

mongous

Technical User
Jun 18, 2002
116
US
I have a data adapter (asp.net) 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!
 
A point in the right direction, would probably to point out that this is probably better addressed in a forum for ASP;-)

I would guess either forum333 or forum855

One little hint on the dates, however, is if you're not using US date format, then explicitly format them to US recognizable dates. In Access one would use the format function:

[tt]...Row_Date BETWEEN #" & format$(StartDate.Text,"yyyy-mm-dd") & "#... [/tt]

There are probably appropriate methods within ASP too?

Roy-Vidar
 
Yeah, I posted there originally, and someone suggested to try it here. [dazed]

I have actually tried 3 different forums! Thanks for the advice though!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top