on 07-21-2014 7:45 PM
Background: winform app using Cr for VS (SP10), VS2013, ODBC connection to SQL Server.
Using Crystal Reports Designer, Set Data Source Location, one can manually blank out just the 'Database' property for an ODBC data source. This causes the Database property to be removed from the connection properties. I need to achieve the same effect in code (just at runtime, no need to permanently update the rpt).
Testing with a simple report with a DataSourceConnection(0) that has 3 Logon Properties (Database, DSN, and UseDSNProperties).
Dim MyReportLogonProperties As NameValuePairs2
MyReportLogonProperties = ReportN.DataSourceConnections(0).LogonProperties.Clone
MyReportLogonProperties.Remove(MyReportLogonProperties.LookupNameValuePair("Database"))'
' note: at this point the number of LogonPropeties in the clone is indeed down to 2.
ReportN.DataSourceConnections(0).SetLogonProperties(MyReportLogonProperties)
' at this point, there are 5 LogonProperties: DSN, PreQEDatabaseName, PreQEServerName, Trusted_Connection, UseDSNProperties
I believe the PreQEDatabaseName that is added for some reason by the runtime is blocking the attempt to remove the 'Database' property.
To recap: is there a way to remove just the 'Database' property from the LogonProperties of a DataSourceConnection?
Hi Ido,
Thank you for posting this to SCN....
Pre-CR 9 days when you could remove the database name from the connection info CR would "pickup" the database from the connection you had open because you had to be connected to a DB before you could do anything in the Designer. When we completely re-wrote the database connectors and removed it from the crw32.exe they created a new QueryEngine and CRQE dll's thus we removed all "custom" DB driver "hacks" from the dll's which forced DB Clients to "follow the rules". ( too tough to maintain )
Since then CR 9 and above fully qualifies all Database info in it's field references and anything related to a database name, table and field.
If you run in debug mode you can see this, for MS SQL it's typically Database.dbo.table. If we don't fully qualify and someone else owns a table of the same name you were never sure which DB you actually got data from ( all depended on where the pointer was on the Server and if there were multiple DB connection in the Designer - Subreport to the same Server and different Schema with same table name but different Database as an example). CR only has one HDBC handle but spawns multiple Handles over the same connection.
So now all of this info is saved in the RPT file and there is no way to not save it even at runtime, because all field references must have a fully qualified source so CR knows exactly where to get the data from.
So even though you are blanking out the Database properties in UI, in the backend we still have it fully qualified and therefore will not allow you to blank it out in the SDK. And it actually makes no sense to set it blank because now CR has no idea how to build the SQL because MS doesn't allow dbo.table to be used.
Bottom line is even setting it to nothing in CR Designer the rpt still has it referenced because you had to select it when you designed the report, it's just the UI allowing you to blank it out.
And it's not clear why you want to do this? You still need to set it so why start from nothing, you are simply replacing it anyways in code. Security issue possibly???
Hope that explains it?
Thanks again
Don
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
81 | |
25 | |
12 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.