Results 1 to 3 of 3

Thread: Problem with ConnectionProperties

  1. #1

    Thread Starter
    New Member
    Join Date
    Jan 2008
    Posts
    1

    Question Problem with ConnectionProperties

    Hey.
    Sory for C#...

    I have report created in CR 11 Pro:

    In Database -> Set datadource location:

    HTML Code:
    MyServer\sql_2005
       -> Properties
            Database Type: ODBC (RDO)
            Connection String: DRIVER={SQL Server};SERVER=MyServer\sql_2005;DATABASE=CRDataBase
            User ID: MyUser
            Database: CRDataBase
            SERVER: MyServer\sql_2005
            Use DSN Default Properties: False
    and for each table like this:
    HTML Code:
       -> Magazyny
            -> Properties
                Table Name: Magazyny 
                Table Type: Tables
                Catalog: CRDataBase
                Owner: MyUser
    Setting: Save data with Report = off

    Ok. I try to use this file in crystal viewer control.


    Code:
    crReport = crApp.OpenReport(@"C:\Raport1.rpt", 1);
    
    crReport.DiscardSavedData();
    
    k_Viewer.ReportSource = crReport;
    k_Viewer.ViewReport();
    And the report run fine but when i change (in SQL Server Management Studio) the name of database from CRDataBase to XDataBase i have error:

    System.Runtime.InteropServices.COMException (0x80047E48): Logon failed.
    Details: 01S00:[Microsoft][ODBC SQL Server Driver]Invalid connection string attribute.


    Logon failed couse database name has changed.

    so a try to change connection string for each tables:
    full code:
    Code:
    crReport = crApp.OpenReport(@"C:\Raport1.rpt", 1);
    
    crReport.DiscardSavedData();
    
    for (int i = 1; i < crReport.Database.Tables.Count; i++)
    {
    crReport.Database.Tables[i].ConnectionProperties.DeleteAll();
    crReport.Database.Tables[i].ConnectionProperties.Add("Connection String", @"Driver=SQL Server;Server=" + _Server + ";Database=" + _DataBase + ";UID=MyUser;PWD=");
    }
    
    k_Viewer.ReportSource = crReport;
    k_Viewer.ViewReport();
    and the next error:

    System.Runtime.InteropServices.COMException (0x80047E44): The table '' could not be found.

    what the ... ??

    ok.. i try to change database name to old "CRDataBase" and all run fine.
    so a created new database with name "CRNew" withe the same structures as "CRDataBase".

    report run fine but data was loaded from old database.

    so i try to change location of all tables:
    full code:

    Code:
    crReport = crApp.OpenReport(@"C:\Raport1.rpt", 1);
    
    crReport.DiscardSavedData();
    
    for (int i = 1; i < crReport.Database.Tables.Count; i++)
    {
    String oldLocation = crReport.Database.Tables[i].Location;
    
    crReport.Database.Tables[i].ConnectionProperties.DeleteAll();
    crReport.Database.Tables[i].ConnectionProperties.Add("Connection String", @"Driver=SQL Server;Server=" + _Server + ";Database=" + _DataBase + ";UID=MyUser;PWD=");
    
    String newLocation = _DataBase + "." + "MyUser" + "." + oldLocation;
    crReport.Database.Tables[i].Location = newLocation;
    
    }
    
    k_Viewer.ReportSource = crReport;
    k_Viewer.ViewReport();
    and data from new database was loaded...

    ok.. at the and i delete the old database "CRDataBase" i **** the same error:

    System.Runtime.InteropServices.COMException (0x80047E44): The table '' could not be found.

    what the... ??

    what is with this report ??
    why after the changing connection string report do not work on other database??

    what else i must do ?

    2 fu*** day and nothing..

    i must figure this today...

  2. #2
    Addicted Member Cristian's Avatar
    Join Date
    Jun 2006
    Posts
    228

    Smile Re: Problem with ConnectionProperties

    Why you don't try with active data. You only set the setdatasource property to an valid recordset and it will works!!

  3. #3
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758

    Re: Problem with ConnectionProperties

    Its been a very very long time since I did any C coding and may not remember how the For loop works.

    But aren't you missing the last table. Shouldn't it be looping from 1 to Count.

    for (int i = 1; i <= crReport.Database.Tables.Count; i++)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width