Showing posts with label related. Show all posts
Showing posts with label related. 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

How to change column order of a table

Hi,
I need to modify column order of some of my sql server 2k tables
because i want to keep related columns together. How can i do this?
Thanks
Nikhilcreate a view with the columns in the order you want

rudy|||Why?

If you really need to do it.

create an new table as you want the columns to be.

Copy the data into it.

rename the old table to a different name.

rename the new table to the old name.

Fix all the Foreign keys to point to the correct table.

and pray it works!!!

I would suggest getting an book on SQL design because there is normaly no good reason to change the column order of the table.

Tim S|||It's very simple use Enterprise Manager -> Tables _> Design Table -> and use drag and drop to move one column in the position you want (it' necessary to select the row of the column in order for drag and drop to function)

Beware, this only can be done in SQL Server 2k not in any previous versions of SQL Server.

Anyway to move a column has a meaning only for a better visualisation of the table design, because the order of columns, or the phisical order of rows in the table has no importance (it's a base rule of relational database).
But, if you decide to move one column before another, you can do it nothing is going to change within your application.

In fact, there is one problem in SQL 2k. If you are changing the position of a column and for that table you have a trriger that use the function COLUMNS_UPDATED(n) (where n is the no of a row in the table) and after your switching positions of columns the positin of the column implied in COLUMN_UPDATED function changes you should modify your trriger in order to work corectly.

IONUT