Data Connectivity
 Crystal Reports Forum : Crystal Reports for Visual Studio 2005 and Newer : Data Connectivity
Message Icon Topic: Connect to Multiple Tables: Some Linked, Some Not Post Reply Post New Topic
Author Message
ssmith147
Newbie
Newbie


Joined: 26 Aug 2008
Online Status: Offline
Posts: 3
Quote ssmith147 Replybullet Topic: Connect to Multiple Tables: Some Linked, Some Not
    Posted: 17 Sep 2008 at 2:51pm
Hi,
 
I'm trying to connect to a database through a dataset (not external DLL file).  I was having trouble initially because I don't know how to connect to a SQL Server 2005 CE database.  I eventualy got around that by using the dataset and the following code:

Private Sub btnSelectReport_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSelectReport.Click

If Me.txtReportName.Text = "" Then

MsgBox("Please select a report file before proceeding.")

Exit Sub

End If

strFileName = "rassdk://" + Me.txtReportName.Text

Me.ReportFile.FileName = strFilename

Try

'This code is designed to be dynamic to allow access to multiple datasets based on numbers tacked on to the end of the report file.
'For the record, I hate doing it this way, but its all I've got right now
 
intDSNumber = CType(strFilename.Substring(strFilename.IndexOf("--", 1) + 2, 1), Integer)

intTableNumber1 = CType(strFilename.Substring(strFilename.IndexOf("--", 1) + 3, 1), Integer)

intTableNumber2 = CType(strFilename.Substring(strFilename.IndexOf("--", 1) + 4, 1), Integer)

intTableNumber3 = CType(strFilename.Substring(strFilename.IndexOf("--", 1) + 5, 1), Integer)

Catch ex As Exception

MsgBox(ex.Message & vbNewLine & vbNewLine & "This may not be a valid AdvancedPFM Report File")

End Try

Try

Select Case intDSNumber

Case 0

Me.TblCustomersTableAdapter.Fill(Me.DsCustomersReports.tblCustomers)

Me.ReportFile.SetDataSource(DsCustomersReports.Tables(intTableNumber1))

Case 1

Me.TblCustomersTableAdapter2.Fill(Me.DsPlayerTypeReports.tblCustomers)

Me.TblDateVisitedTableAdapter.Fill(Me.DsPlayerTypeReports.tblDateVisited)

Me.ReportFile.SetDataSource(DsPlayerTypeReports.Tables())

Case Else

MsgBox("Incompatible report. Check for software updates.")

End Select

Catch ex As Exception

MsgBox(ex.Message)

End Try

Try

Me.CrystalReportViewer1.ReportSource = Me.ReportFile

Catch ex As Exception

MsgBox(ex.Message & vbNewLine & vbNewLine & "This may not be a valid AdvancedPFM Report File")

End Try

End Sub

As you can tell, this method is very limited in the number of datasets I program in.  Plus, because I'm using the SetDataSource method, I can only designate one table as the source of the information- at least, that what I think at this point.
 
1- Is there a better way to connect to the database which doesn't require any of this stuff from the file name? 
 
2- If not, how can I connect to two different tables in the dataset where the data is not linked?
 
3- Also, how can I connect to two different tables in the dataset where one table's records are dependent on their existence in the other table? Or, I;m looking for records in one table that are child records from something in the first table?
 
I really hope you can help me with this because making a more dynamic report experience is critical to my software.
 
Thanks for whatever help is offered!
 
-Will
IP IP Logged
Post Reply Post New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum



This page was generated in 0.016 seconds.