|
-
Feb 15th, 2006, 09:30 AM
#1
Thread Starter
New Member
2 tables 1 report issue
I have created a report in CR XI that uses 2 tables from an access database. 2 fields are from one table and the 3rd field is from the other. When I preview the report in CR, it gives me the correct results.
User1
Site1
Site2
Site3
When I call the report in VB.NET 2003 it duplicates the results.
User1
Site1
Site1
Site1
Site2
Site2
Site2
Site3
Site3
Site3
Here is the code that I am calling the report in VB.NET.
strsql = "SELECT tblUser.UserName, tblUser.Administrator, Security_Access.Site_ID FROM tblUser INNER JOIN Security_Access ON tblUser.UserName = Security_Access.UserName"
reportname = apppath & "\rpt_users.rpt"
Dim con As New OleDb.OleDbConnection
'Create a connection to specified database
con = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & inpdatabase & ";")
'Open connection
con.Open()
da = New OleDb.OleDbDataAdapter(strsql, con)
da.Fill(ds, "User")
con.Close()
rd = New ReportDocument
rd.Load(reportname)
rd.SetDataSource(ds)
crvMain.ReportSource = rd
Thanks
mmars
-
Feb 16th, 2006, 04:14 AM
#2
Re: 2 tables 1 report issue
strsql = "SELECT tblUser.UserName, tblUser.Administrator, Security_Access.Site_ID FROM tblUser INNER JOIN Security_Access ON tblUser.UserName = Security_Access.UserName"
VB Code:
strsql = "SELECT Distinct tblUser.UserName, tblUser.Administrator, Security_Access.Site_ID FROM tblUser INNER JOIN Security_Access ON tblUser.UserName = Security_Access.UserName"
If an answer to your question has been helpful, then please, Rate it!
Have done Projects in Access and Member management systems using BioMetric devices, Smart cards and BarCodes.
-
Feb 16th, 2006, 09:28 AM
#3
Thread Starter
New Member
Re: 2 tables 1 report issue
Thanks for your reply but DISTINCT and DISTINCTROW did not work. I'm still getting the duplicate records.
mmars
-
Feb 20th, 2006, 01:14 AM
#4
Junior Member
Re: 2 tables 1 report issue
I don't know what and how is the information stored in the two tables. Did you try to copy the query into Query Analyzer?... Maybe you must modify the JOIN... (Perhaps a LEFT or RIGHT?)
Regards,
Tribo
Last edited by Tribo; Feb 20th, 2006 at 01:20 AM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|