Showing posts with label directly. Show all posts
Showing posts with label directly. Show all posts

Wednesday, March 21, 2012

How to change datasource location without having to connect to target database?

I know this is not related directly to Visual Basic, but maybe I can get some helpful feedback here.

We have developed a CR XI report using a local SQL Server database and several tables/views from it. The way we normally change the database a report uses is by going to the Change Datasource Location menu option, creating a new connection to the database and mapping both the main report and each table/view in the report to the new datasource and the new tables/views.

This is what I mean:
http://img411.imageshack.us/img411/9236/crmain8wz.jpg (general report connection properties)
http://img92.imageshack.us/img92/3397/crtable4zp.jpg (specific table/view connection properties)

We now need to distribute this report to the client and need to change the database the report uses. We have the name of the server and database at the client's site, but we obviously have no access to connect to it.

How do we change the datasource location in this case?

Thank you in advance.By the way, I tried using the code in this Microsoft page:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/crystlrf/html/crlrftableclassapplylogoninfomethodtopic.asp

The code is:

Private Sub LogonToReport (ByVal server As String, ByVal database As String, ByVal ID As String, ByVal password As String)
Dim logonInfo As New TableLogOnInfo()
Dim table As Table

' Set the logon information for each table.
For Each table In Report.Database.Tables
' Get the TableLogOnInfo object.
logonInfo = Table.LogOnInfo
' Set the server or ODBC data source name, database name,
' user ID, and password.
logonInfo.ConnectionInfo.ServerName = server
logonInfo.ConnectionInfo.DatabaseName = database
logonInfo.ConnectionInfo.UserID = ID
logonInfo.ConnectionInfo.Password = password
' Apply the connection information to the table.
Table.ApplyLogOnInfo(logonInfo)
Next table
End Sub

(Although I actually used the C# variant, but this is a VB forum.)

The second the ApplyLogOnInfo method is called, the CR component tries to connect to the database. WHY? Is there a way to avoid this?|||I have used this same code and I still have a problem
The connection details are passed using an ini file.
When developing the report (the actual rpt file) we have one database e.g. db1. When the report is copied to the production server we have another database name e.g. db2
The report rpt file holds on to the first name (db1), even though the c# code is showing the database name passed is db2.
Does anyone out there know a way to get the report to use the new database name?sql

Friday, February 24, 2012

How to build SQL Commands in a Remote Database Component

Hello,

I'm trying to develop a remote database component for the server that interacts with the database directly. I would like to pass in my object to the corresponding add, update, delete methods and have the database component generate the script to do the corresponding transaction to the database. However, I cannot find a viable solution yet. The only method that I have found so far is passing the exact SQL command to the database component for it to execute. This would require making a 3 SQL Statement (one for add, update, and delete) for each class.

Thanks,

Kiet Quach

I would back up a bit here. I think your approach is flawed.

your objects should be MarshalByValue/serializable. the object should be passed across the wire to a service, the object then would process itself as it should know how to manipulate its own contents.

I highly recommend Lhotka's Expert C# business objects

"object-oriented" means orient to the object.

What you are proposing is a "service-oriented" data access solution and I wouldn't recommend that for data processing. On the other hand, A hybrid achitecture - a solution that services self contained data objects object is quite appropriate.

|||Thanks Blair for the input. However, there is a reason why I wanted to only pass the object, I want to maintain database independence since my customers use a different database platform. Therefore, it would be a lot more scalable if I could create the SQL commands in the database component.

Kiet Quach|||thats what I am saying. . . read lhotka!