I am trying to use crystal reports again with Linq but I am having problems. I have read a diverse amount of forums and articles on how this should be done but I am not sure what I could be doing wrong.
1st Method Tried
Dim DBDataContext = GetDataConnection()
Dim cryRpt As IBS_DAL.cryLocationTransfer = New IBS_DAL.cryLocationTransfer()
cryRpt.Load(cryRpt.FileName)
Dim testDS = From stl In DBDataContext.STranLines
Where stl.STLStkRef >= "000000000330" AndAlso
stl.STLStkRef <= "000000000337" AndAlso
(stl.STLTranCode = "LI" Or stl.STLTranCode = "LO")
Select stl.ToRepObj
cryRpt.SetDataSource(testDS.ToList)
CrystalReportViewer1.ReportSource = cryRpt
ToRepObj is currently setting to a class which I made so that it will use a object which doesn’t have null value.
But when the report loads it is asking for a password which makes absolutely no sense as I am feeding it the data.The server name is the .net object which I had previously set in the report.
I really need to find a solution as I was previously using Microsoft Reporting but found some areas that are lacking and thus decided that it would be best to use Crystal but have never used it with Linq.
2nd Method Tried
I have also tried another way which I have seen on this website but for some reason it is giving me a blank report.The .Net Object are linked on stkcode in crystal report.
Dim testDS = (From stl In DBDataContext.STranLines
Where stl.STLStkRef >= "000000000330" AndAlso
stl.STLStkRef <= "000000000337" AndAlso
(stl.STLTranCode = "LI" Or stl.STLTranCode = "LO")
Select stl)
Dim ds1 = (From stl As STranLine In testDS
Select stl.ToRepObj).ToList
Dim ds2 = (From stl As STranLine In testDS
Select stl.Stock.ToRepObj).ToList
Dim cryrpt2 As ReportDocument = New IBS_DAL.CrystalReport1()
cryrpt2.Database().Tables("IBS_DAL_roSTranLine").SetDataSource(ds1)
cryrpt2.Database().Tables("IBS_DAL_roStock").SetDataSource(ds2)
CrystalReportViewer1.ReportSource = cryrpt2
try this maybe helpful