Setting Information at Runtime ("Server has not yet been opened" - again) 
Author Message
 Setting Information at Runtime ("Server has not yet been opened" - again)

Hi All,

I have been struggeling with a problem for the last week or so and it
is really starting to bug me.  Set up is as follows:

Crystal Reports 8.5
VB6 Application
Access 2000 (with password)

I have a report that is connecting to the access database using OLE
DB.  I can verify the database in the designer, but when I try to run
the report from the application (even on the development machine) I
get the familiar "Server had not yet been opened".  I have read almost
every post I could find on this subject and nothing seems to help.  I
have tried various combinations of:

MyReport.Database.Tables(1).Location = strConnection

Call MyReport.Database.Tables(1).SetLogOnInfo(strConnection,
strDatabaseFilename, strUname, strPassword)

Call MyReport.Database.LogOnServer("p2soledb.dll",
MyReport.Database.Tables(1).LogOnServerName,
MyReport.Database.Tables(1).LogOnDatabaseName, "admin", "mypassword")

MyReport.Database.SetDataSource (strConnection)

(Where strConnection="PROVIDER=Microsoft.Jet.OLEDB.4.0;Data
Source=myDatabase.mdb;Jet OLEDB:Database Password = mypassword")

Any help or ideas would be greatly appreciated.

Thanks in advance,

Mike



Tue, 01 Nov 2005 21:56:12 GMT  
 Setting Information at Runtime ("Server has not yet been opened" - again)
Have you tried monkeying with the
Report.Database.Tables.Item.ConnectionProperties items? An approach that I
used when working with 8.5 was to loop through the tables and set the DSN as
such:

set crtables = objReport.Database.Tables
for each tblTemp in crtables
    with tblTemp.ConnectionProperties
        .Item("DSN") = "MyDatabase"
    end with
next

You'll need to set up a DSN to point to your database, of course.


Quote:
> Hi All,

> I have been struggeling with a problem for the last week or so and it
> is really starting to bug me.  Set up is as follows:

> Crystal Reports 8.5
> VB6 Application
> Access 2000 (with password)

> I have a report that is connecting to the access database using OLE
> DB.  I can verify the database in the designer, but when I try to run
> the report from the application (even on the development machine) I
> get the familiar "Server had not yet been opened".  I have read almost
> every post I could find on this subject and nothing seems to help.  I
> have tried various combinations of:

> MyReport.Database.Tables(1).Location = strConnection

> Call MyReport.Database.Tables(1).SetLogOnInfo(strConnection,
> strDatabaseFilename, strUname, strPassword)

> Call MyReport.Database.LogOnServer("p2soledb.dll",
> MyReport.Database.Tables(1).LogOnServerName,
> MyReport.Database.Tables(1).LogOnDatabaseName, "admin", "mypassword")

> MyReport.Database.SetDataSource (strConnection)

> (Where strConnection="PROVIDER=Microsoft.Jet.OLEDB.4.0;Data
> Source=myDatabase.mdb;Jet OLEDB:Database Password = mypassword")

> Any help or ideas would be greatly appreciated.

> Thanks in advance,

> Mike



Wed, 02 Nov 2005 02:56:43 GMT  
 Setting Information at Runtime ("Server has not yet been opened" - again)
Thanks for your suggestion.  However we do not want to set up a DSN on
the end users computer.  We played with idea for a while and it did
work, but we are keen to avoide using a dsn if at all possible.


Fri, 04 Nov 2005 22:46:55 GMT  
 Setting Information at Runtime ("Server has not yet been opened" - again)
One thing I forgot to ask...are you using subqueries? If so, you need to
loop through the subqueries in your report and do the same as with the
initial table. I'm being lazy and posting the code I have on another thread
here that uses the .Net namespace for Crystal Reports, but you get the idea.

          crConnectionInfo = New ConnectionInfo()

            With crConnectionInfo
                .ServerName = ServerName
                .DatabaseName = DatabaseName
                .UserID = UserId
                .Password = Password
            End With

            For Each crTable In m_objReport.Database.Tables
                crTableLogonInfo = crTable.LogOnInfo
                crTableLogonInfo.ConnectionInfo = crConnectionInfo
                crTable.ApplyLogOnInfo(crTableLogonInfo)
            Next

            For Each crSection In m_objReport.ReportDefinition.Sections
                For Each crReportObject In crSection.ReportObjects
                    If crReportObject.Kind
=CrystalDecisions.[Shared].ReportObjectKind.SubreportObject Then
                        crSubReport = CType(crReportObject,
CrystalDecisions.CrystalReports.Engine.SubreportObject)
                        crSubReportDoc
=crSubReport.OpenSubreport(crSubReport.SubreportName)
                        For Each crTable In crSubReportDoc.Database.Tables
                            crTableLogonInfo = crTable.LogOnInfo
                            crTableLogonInfo.ConnectionInfo
=crConnectionInfo
                            crTable.ApplyLogOnInfo(crTableLogonInfo)
                        Next
                    End If
                Next
            Next

            crConnectionInfo = Nothing

I feel your pain. I am struggling to find an answer to how to change a
datasource location dynamically. Using the techniques recommended from
Crystal using the .Net components (as above) does not change the data
source. It will authenticate against the data source that I choose, but it
will pull data from the original data source. Go figure. See my other post
in this newsgroup for more detail.


Quote:
> Thanks for your suggestion.  However we do not want to set up a DSN on
> the end users computer.  We played with idea for a while and it did
> work, but we are keen to avoide using a dsn if at all possible.



Sat, 05 Nov 2005 05:38:49 GMT  
 Setting Information at Runtime ("Server has not yet been opened" - again)
Hi Kevin,

I haven't yet figured by current problem unfortunately, but I did
struggle with the .NET crystal reports and changing location, and I
finally did figure that one out.  My code below should solve your
problem on .NET.  The extra line needed to change the datasource is
"tbCurrent.Location = tliCurrent.TableName".  This should allow you to
change database dynamically. Note that the query/stored procedure
can't have a different alias in the crystal report (e.g. if your
stored prodecure is called sp_GetData then your location AND alias in
the Crystal Report need to be called "sp_GetData").  Hope the code
below helps you out (note that the extra line is needed for sub
reports as well).

        For Each tbCurrent In myReport.Database.Tables
            tliCurrent = tbCurrent.LogOnInfo
            With tliCurrent.ConnectionInfo
                .ServerName = strDBServer
                .UserID = strDBUName
                .Password = strDBPassword
                .DatabaseName = strDBName
            End With
            tbCurrent.ApplyLogOnInfo(tliCurrent)
            tbCurrent.Location = tliCurrent.TableName
        Next tbCurrent

        crSections = myReport.ReportDefinition.Sections

        For Each crSection In crSections
            crReportObjects = crSection.ReportObjects
            For Each crReportObject In crReportObjects
                If crReportObject.Kind =
ReportObjectKind.SubreportObject Then

                    'If you find a subreport, typecast the
reportobject to a subreport object

                    crSubreportObject = CType(crReportObject,
SubreportObject)
                    subRepDoc =
crSubreportObject.OpenSubreport(crSubreportObject.SubreportName)

                    crDatabase = subRepDoc.Database
                    crTables = crDatabase.Tables

                    For Each crTable In crTables
                        With crConnInfo
                            .ServerName = strDBServer
                            .UserID = strDBUName
                            .Password = strDBPassword
                            .DatabaseName = strDBName
                        End With
                        crLogOnInfo = crTable.LogOnInfo
                        crLogOnInfo.ConnectionInfo = crConnInfo
                        crTable.ApplyLogOnInfo(crLogOnInfo)
                        crTable.Location = crLogOnInfo.TableName
                    Next

                End If
            Next
        Next



Sat, 05 Nov 2005 19:05:11 GMT  
 Setting Information at Runtime ("Server has not yet been opened" - again)
Yeah, I've tried a half dozen variants of that approach. What it does is
cause exceptions to be thrown in every formula I have in the
report...reporting that that table doesn't exist. Once I remove the
formulae, it returns no data...as if the data source didn't exist.


Quote:
> Hi Kevin,

> I haven't yet figured by current problem unfortunately, but I did
> struggle with the .NET crystal reports and changing location, and I
> finally did figure that one out.  My code below should solve your
> problem on .NET.  The extra line needed to change the datasource is
> "tbCurrent.Location = tliCurrent.TableName".  This should allow you to
> change database dynamically. Note that the query/stored procedure
> can't have a different alias in the crystal report (e.g. if your
> stored prodecure is called sp_GetData then your location AND alias in
> the Crystal Report need to be called "sp_GetData").  Hope the code
> below helps you out (note that the extra line is needed for sub
> reports as well).

>         For Each tbCurrent In myReport.Database.Tables
>             tliCurrent = tbCurrent.LogOnInfo
>             With tliCurrent.ConnectionInfo
>                 .ServerName = strDBServer
>                 .UserID = strDBUName
>                 .Password = strDBPassword
>                 .DatabaseName = strDBName
>             End With
>             tbCurrent.ApplyLogOnInfo(tliCurrent)
>             tbCurrent.Location = tliCurrent.TableName
>         Next tbCurrent

>         crSections = myReport.ReportDefinition.Sections

>         For Each crSection In crSections
>             crReportObjects = crSection.ReportObjects
>             For Each crReportObject In crReportObjects
>                 If crReportObject.Kind =
> ReportObjectKind.SubreportObject Then

>                     'If you find a subreport, typecast the
> reportobject to a subreport object

>                     crSubreportObject = CType(crReportObject,
> SubreportObject)
>                     subRepDoc =
> crSubreportObject.OpenSubreport(crSubreportObject.SubreportName)

>                     crDatabase = subRepDoc.Database
>                     crTables = crDatabase.Tables

>                     For Each crTable In crTables
>                         With crConnInfo
>                             .ServerName = strDBServer
>                             .UserID = strDBUName
>                             .Password = strDBPassword
>                             .DatabaseName = strDBName
>                         End With
>                         crLogOnInfo = crTable.LogOnInfo
>                         crLogOnInfo.ConnectionInfo = crConnInfo
>                         crTable.ApplyLogOnInfo(crLogOnInfo)
>                         crTable.Location = crLogOnInfo.TableName
>                     Next

>                 End If
>             Next
>         Next



Mon, 07 Nov 2005 02:06:42 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. "the server is not yet opened"

2. Error: "Server not yet opened"

3. "Server not yet opened"

4. "server not yet opened" error

5. "server not yet opened" error

6. Connection not Open + Server has not yet been opened error messages

7. Help on "function not yet implemented"

8. Yet again "Server has not yet been opened"

9. "Server not yet opened" Error when opening report form

10. VB6, CRP7, SQL-server "Server has not yet been opened" message.

11. "License information not found"

12. Server has not yet been opened message with VB6, CRP7 and SQL-server

 

 
Powered by phpBB® Forum Software