Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Report name as variable?
Message
From
23/06/2004 09:46:32
 
General information
Forum:
ASP.NET
Category:
Reporting
Miscellaneous
Thread ID:
00916127
Message ID:
00916393
Views:
7
Jeff,

>Thanks but I was looking for something much easier. I think I misled you with the 'instantiate' in my question.

Yep, I haven't used Crystal at all, so I didn't know what was necessary to load a report. In your original question you used oRpt = New MyReportName as your example, so it looked like an instantiation issue. Anyway, it turns out to be just a parameter passing issue and you figured it out, so that's cool. =)

~~Bonnie


>
>The following works for anyone interested.
>
>Dim orpt As New CrystalDecisions.CrystalReports.Engine.ReportDocument
>dim RptPath , RptName as string
>RptPath = "C:\inetpub\wwwroot\mydir\"
>RptName = Request.form("RequestedRptName")+".rpt"
>orpt.Load(RptPath + RptName)
>
>
>>Hey Jeff,
>>
>>I don't know anything about Crystal, but it sounds like you need to use reflection to get at this. Here's an example of using reflection:
>>
>>string DLLName = "MyDLL";
>>string ClassName = "MyClass";
>>System.Reflection.Assembly oDLL;
>>object oClass;
>>
>>// This "loads" the .DLL
>>oDLL = System.Reflection.Assembly.LoadFrom(DLLName);
>>
>>// This creates the class instance
>>oClass = oDLL.CreateInstance(ClassName);
>>
>>And if you need to pass parameters
>>
>>// Create an instance of the desired form from the assembly
>>object [] args = new object[1];
>>args[0] = MyKey;
>>oForm = (Form)oDLL.CreateInstance(classname, true, System.Reflection.BindingFlags.CreateInstance, null, args, null, null);
>>
>>I hope this points you in the right direction.
>>
>>~~Bonnie
>>
>>
>>>Can I use a variable to instantiate a report?
>>>
>>>Like
>>>
>>>dim myreportname as string
>>>Dim orpt As CrystalDecisions.CrystalReports.Engine.ReportDocument
>>>
>>>myreportname = "myreport1"
>>>orpt = New myreportname
>>>
>>>This does not work. Is there a way??
>>>
>>>Jeff
Bonnie Berent DeWitt
NET/C# MVP since 2003

http://geek-goddess-bonnie.blogspot.com
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform