I am trying to create a dynamic crystal report at run time from Visual Studio 2013 using C#. My back end database is SQL Server 2005. The source for my crystal report is a SQL Server stored procedure which takes two parameters, a year (smallint) and a quarter (tinyint). The stored procedure uses dynamic SQL and creates a dynamic temp table. It returns the result set from a select on the temp table. The number of columns in the result set will be determined at run time. Right now it returns 40 columns. It can return additional columns in multiples of 6. All of these columns will need to be displayed on the crystal report at run time. The C# application will run on 64 bit Windows 7 machines and the SQL Server database is on a 32 bit server.
I have been successful in designing a crystal report within the Visual Studio IDE using this stored procedure and running it and displaying it in the crystal reports viewer from within the C# application. So when the appropriate application's menu item is clicked, the form with the crystal viewer on it opens and displays the report. So I know that I can connect to the database and display the report. However as stated in the preceding paragraph, I need to create the crystal report at run time as the number of columns on the report will be variable.
I have looked at the CrystalDecisions SDK and API and tried without success to do this. I am getting errors when trying to connect to the DB through the API and am not able to retrieve the data. I have played with the code for about a week with no success. I have tried the code in the discussion forums without success. The documentation for the SDK API's does not provide the level of detail that I need. The CrystalDecisions.ReportAppServer.DataDefModel.ConnectionInfo class has an attributes property that needs to be set. I don't know what the proper settings should be.
I prefer to use the OLE DB native client for SQL Server.
Any help would be greatly appreciated.
Martin