?
Solved

CR 8.5 / VB 6.0 / ODBC dsn ; Change Server/database at run time ; URGENT!!!!!!!!!!

Posted on 2005-03-08
7
Medium Priority
?
5,114 Views
Last Modified: 2008-03-04
Hello all,
I have created few reports using CR 8.5. I have used ODBC dsn file to connect to the database (SQL Server). There is a procedure , that takes an input parameter. I am executing it and filling the report. everythings working fine.
Now I need to change the server/database, by pointing to a different dsn file. The new database will have the same procedure in it. Heres what I am doing..

==================================================================================
     Dim Report As CRAXDRT.Report
     Dim RepAppl As New CRAXDRT.Application

    Set Report = RepAppl.OpenReport(App.Path & "/CycleCount_Report" & reportIndex & ".rpt", 1)
    Report.DiscardSavedData

    Dim i As Integer
    For i = 1 To Report.Database.Tables.Count
        Report.Database.Tables.Item(i).SetLogOnInfo App.Path & "/App2_PICS.dsn", "PICS"    ' App2_PICS is my new dsn file
    Next i

    With Report
        .ParameterFields.Item(1).ClearCurrentValueAndRange
        .EnableParameterPrompting = False
        .ParameterFields.Item(1).AddCurrentValue (reportIndex)
    End With

    CRViewer1.ReportSource = Report
    CRViewer1.ViewReport

==================================================================================

But unfortunately it is still using the older connection to the older database. I even deleted the older dsn file.

Any help will be appreciated  !!!!

-Baan
0
Comment
Question by:DotNetLover_Baan
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
7 Comments
 
LVL 13

Expert Comment

by:vidru
ID: 13490516
Put in a Debug.Print line where you're looping to set the login to have a look at the Location property of each table.  It could be using the schema pointing to the old db (e.g. Database1.dbo.ProcName instead of Database2.dbo.ProcName).

For i = 1 To Report.Database.Tables.Count
   With Report.Database.Tables.Item(i)
      .SetLogOnInfo App.Path & "/App2_PICS.dsn", "PICS"    ' App2_PICS is my new dsn file
      Debug.Print .Location
      'I don't use File DSN's, but this next line of code works 99% of the time to 'lose' the schema
      .Location = .Name
   End With
Next i
     
-dave
0
 
LVL 18

Author Comment

by:DotNetLover_Baan
ID: 13490675
Alright.. I figured that out already. But thanks for your help any way...

I think it is very important...... Heres what I should be doing....

    For i = 1 To Report.Database.Tables.Count
        Report.Database.Tables.Item(i).SetLogOnInfo "MyNewDataBase",App.Path & "/App2_PICS.dsn"   ' App2_PICS.dsn is my new dsn file
    Next i

SetLogOnInfo  takes two required parametrs and two optional. they are as follows....
     SetLogOnInfo (ServerName As String, DatabaseName As String, UserID As String, Password As String)

when using ODBC (by a dsn file) ,
    ServerName = "Any name you want to give to the new server" .... (I am using "MyNewDataBase")
    DatabaseName= "Filepath to the dsn file".... (I am using App.Path & "/App2_PICS.dsn")
    UserId = "your user name"      ----- Can leave it blank when using windows authentication
    Password="your password"     ----- Can leave it blank when using windows authentication

Thanks to all....

-Baan
0
 
LVL 13

Expert Comment

by:vidru
ID: 13490950
I just ran a couple of tests.  If you have the DSN set up with the correct database, then leave the DatabaseName parameter as an empty string - it'll read from the DSN.  If not, the the DatabaseName should be the name of the database, not the name of the DSN:

Report.Database.Tables.Item(i).SetLogOnInfo App.Path & "/App2_PICS.dsn", ""

-dave
0
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 18

Author Comment

by:DotNetLover_Baan
ID: 13492038
Hi vidru,
can you please explain that issue to me ? Sounds like something important.

FYI, I did try that...
Report.Database.Tables.Item(i).SetLogOnInfo App.Path & "/App2_PICS.dsn", ""

But still it was reading from the older connection. The bitter part is, I already deleted the older dsn file, so that the report can not use it at run time. I guess it has embaded the connection in it some how. I will do some research on it.

Anyway, I want to understand your point. Please explain...

-Baan
0
 
LVL 13

Expert Comment

by:vidru
ID: 13492332
0
 

Accepted Solution

by:
OzzMod earned 0 total points
ID: 13523588
Closed, 500 points refunded.
OzzMod
Community Support Moderator (Graveyard shift)
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I hate sub reports and always consider them the last resort in any reporting solution.  The negative effect on performance and maintainability is just not worth the easy ride they give the report writer.  Nine times out of ten reporting requirements…
Hot fix for .Net Crystal Reports 10.2.3600.0 to fix problems with sub reports running on 64 bit operating systems ISSUE: Reports which contain subreports fail with error "Missing Parameter Value" DEPLOYMENT SERVER OS: Windows 2008 with 64 bi…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question