PDA

View Full Version : Changing location of databasefiles gives an error



Allan Greis Eriksen
23-Feb-2006, 06:40 AM
Hi there.

I'm trying to change the location of two pervasive database files in a
crystal report (Crystal Reports Developer v. 11) using the new interface
methods. The purpose of the report is to make a export file in cvs
format.

Here are a piece of the code:

Procedure OnInitializeReport Handle hoReport
Handle[] hTableObj
Handle hTest
String sName sBesked
Integer iAkt iMax
Boolean bConnectOk

Forward Send OnInitializeReport hoReport

Get TableObjects of hoReport to hTableObj

Move hTableObj[0] to hTest
Set ComLocation of hTest to "D:\firstfile.dbf"
Move hTableObj[1] to hTest
Set ComLocation of hTest to "D:\secondfile.dbf"

// (Dont mind the File name and location for this example.)


// Test the connection
Move (SizeOfArray(hTableObj)) to iMax
Decrement iMax
For iAkt From 0 to iMax
Get ComTestConnectivity of hTableObj[iAkt] to bConnectOk
If (bConnectOk = False) Begin
Get ComName of hTableObj[iAkt] to sName
Move "The connection to crystal rapport " to sBesked
Append sBesked gsREG " with the table " sName " did not
succeed."
Error DFERR_PROGRAM sBesked
End
Loop

// This goes fine! No errors


End_Procedure


Procedure OnExportReport Handle hoReport
Handle hoExport
String sCSVPath
//
Forward Send OnExportReport hoReport
//

// Or, Export can be set up within the program
Set pbExportPrompt of hoReport to False // suppress prompt for all
export information
Get ExportObject of hoReport to hoExport

Set ComDestinationType of hoExport to crEDTDiskFile
Set ComFormatType of hoExport to crEFTCommaSeparatedValues
Set ComDiskFileName of hoExport to "D:\Test.csv"

End_Procedure // OnExportReport

The crystal object has been set with Set pbAutoLocateDFFiles to False


The connection test runs without any problems, but when the report
actually runs it gives me this error:


Error 4399 COM object method invocation error
Invalid Argument provided.

It happens in this procedure from Ccrystalcraxddrt.pkg for the
InvokeComMethod.

// Exports the report to other formats.
//DOC/ Interface=Public
Procedure ComExport Variant llpromptUser
Handle hDispatchDriver
Get phDispatchDriver to hDispatchDriver
Send PrepareParams to hDispatchDriver 1
Send DefineParam to hDispatchDriver OLE_VT_VARIANT llpromptUser
Send InvokeComMethod to hDispatchDriver 259 OLE_VT_VOID
End_Procedure



If I only change the location for the first file it runs without any
problems. Only if I change the location for the second file it gives me
that error.

What could be the case for that?

--
Regards,

Allan Kim Eriksen
programmer/systemconsolent

www.nordteam.dk

Vincent Oorsprong
24-Feb-2006, 10:36 AM
Alan,

Hard to say what is wrong. But I would check;
- Is there a difference when I use a different database? I see you are
using a DBF file which indicates something like dBase? BTW; If you do
not use the embedded database the property pbAutoLocateDFFiles does not
make a difference at all. Or you must be using the INT file access via
the DataFlex connectivity kit for Crystal Reports.
- What happens when you do not turn the export prompting off?
- Have you installed all the parts of Crystal to do the export?
--
Regards,
Vincent Oorsprong
Data Access Europe B.V.
http://www.dataaccess.nl

Allan Greis Eriksen
1-Mar-2006, 12:22 PM
Hi Vincent.

I've been working quite some more on this and still not able to change
the location without error.

I tried to enumerate the connection properties:

Struct tsCrystalConnectionProperty
String sName
String sValue
String sDescription
End_Struct

Struct tsCrystalTableConnectionProperties
String sName
TsCrystalConnectionProperty[] lsCrystalConnectionProperties
End_Struct


// This procedure enumerates all connection properties for a table.
Procedure DoShowConnectionProperties
Handle[] hTableObj
Handle hoReport hoTable
tsCrystalTableConnectionProperties[] lsTableProperties
Integer iTableCount iTableItem iCPCount iCPItem
Handle hoConnectionProperties
Variant vComConnectionProperties
Variant vComConnectionProperty
Handle hoConnectionProperty
Boolean bAttached
String[] sNames

Get ReportObject to hoReport
Get TableObjects of hoReport to hTableObj
Move (SizeOfArray(hTableObj)) to iTableCount
For iTableItem From 1 to iTableCount
Move hTableObj[iTableitem-1] to hoTable
Get ComName of hoTable to lsTableProperties[iTableItem-
1].sName

Get Create of hoTable U_cCrystalConnectionProperties to
hoConnectionProperties
Get ComConnectionProperties of hoTable to
vComConnectionProperties
Set pvComObject of hoConnectionProperties to
vComConnectionProperties

// Get a list of property names
Get ComNameIDs of hoConnectionProperties to sNames

Get ComCount of hoConnectionProperties to iCPCount
For iCPItem From 1 to iCPCount
Get ComItem of hoConnectionProperties sNames[iCPItem-1]
to vComConnectionProperty
Get Create of hoConnectionProperties
U_cCrystalConnectionProperty to hoConnectionProperty
Set pvComObject of hoConnectionProperty to
vComConnectionProperty

Get ComName of hoConnectionProperty to lsTableProperties
[iTableItem-1].lsCrystalConnectionProperties[iCPItem-1].sName
Get ComValue of hoConnectionProperty to lsTableProperties
[iTableItem-1].lsCrystalConnectionProperties[iCPItem-1].sValue
Get ComDescription of hoConnectionProperty to
lsTableProperties[iTableItem-1].lsCrystalConnectionProperties[iCPItem-
1].sDescription

Send ReleaseComObject of hoConnectionProperty
Send destroy of hoConnectionProperty

Loop

Send releaseComObject of hoConnectionProperties
Send destroy of hoConnectionProperties
Loop
End_Procedure

I did enumerate all connection properties to se what I could be missing.
It showed only one property called "Data File" that contained the full
path and filename of the dbf file. So I guessed upon that changing the
Data File property would be the right way to go

// Sets the location for the DBF file.
Procedure Set DBFLocation Handle hoTable String sDBFFile
Variant vComConnectionProperties vComConnectionProperty
Handle hoConnectionProperties hoConnectionProperty

Get Create of hoTable U_cCrystalConnectionProperties to
hoConnectionProperties
Get ComConnectionProperties of hoTable to
vComConnectionProperties
Set pvComObject of hoConnectionProperties to
vComConnectionProperties
Get ComItem of hoConnectionProperties "Data File" to
vComConnectionProperty
Get Create of hoConnectionProperties U_cCrystalConnectionProperty
to hoConnectionProperty
Set pvComObject of hoConnectionProperty to vComConnectionProperty

Set ComValue of hoConnectionProperty to sDBFFile

Send ReleaseComObject of hoConnectionProperty
Send destroy of hoConnectionProperty
Send ReleaseComObject of hoConnectionProperties
Send destroy of hoConnectionProperties
End_Procedure


Set DBFLocation hTableObj[0] to "D:\firstfile.dbf"
Set DBFLocation hTableObj[1] to "D:\secondfile.dbf"

…but it gave exactly the same error as before.


--
Regards,
Allan Kim Eriksen
Programmer/systemconsolent

Nordteam Gruppen Aps
Denmark

David Martinko
1-Mar-2006, 12:34 PM
Try only setting the connection properties for the first table, and then
just the location for the others DLL and stuff for the other tables. I also
got errors when attempting to create the database connection when it already
existed in another table.

--
David Martinko
248-535-7495
Tracker Systems, Inc.
Redeemed Software
Redeemed Hosting
www.trackersys.com
www.redeemedsoftware.com
www.redeemedhosting.com
Proud member of the Northeast DataFlex Consortium: (NEDC)
www.NEDataFlex.com

"Allan Kim Eriksen" <ake@nordteam.dk> wrote in message
news:Xns9779BAF34D2F0AllanKimEriksen@192.245.64.24 0...
Hi Vincent.

I've been working quite some more on this and still not able to change
the location without error.

I tried to enumerate the connection properties:

Struct tsCrystalConnectionProperty
String sName
String sValue
String sDescription
End_Struct

Struct tsCrystalTableConnectionProperties
String sName
TsCrystalConnectionProperty[] lsCrystalConnectionProperties
End_Struct


// This procedure enumerates all connection properties for a table.
Procedure DoShowConnectionProperties
Handle[] hTableObj
Handle hoReport hoTable
tsCrystalTableConnectionProperties[] lsTableProperties
Integer iTableCount iTableItem iCPCount iCPItem
Handle hoConnectionProperties
Variant vComConnectionProperties
Variant vComConnectionProperty
Handle hoConnectionProperty
Boolean bAttached
String[] sNames

Get ReportObject to hoReport
Get TableObjects of hoReport to hTableObj
Move (SizeOfArray(hTableObj)) to iTableCount
For iTableItem From 1 to iTableCount
Move hTableObj[iTableitem-1] to hoTable
Get ComName of hoTable to lsTableProperties[iTableItem-
1].sName

Get Create of hoTable U_cCrystalConnectionProperties to
hoConnectionProperties
Get ComConnectionProperties of hoTable to
vComConnectionProperties
Set pvComObject of hoConnectionProperties to
vComConnectionProperties

// Get a list of property names
Get ComNameIDs of hoConnectionProperties to sNames

Get ComCount of hoConnectionProperties to iCPCount
For iCPItem From 1 to iCPCount
Get ComItem of hoConnectionProperties sNames[iCPItem-1]
to vComConnectionProperty
Get Create of hoConnectionProperties
U_cCrystalConnectionProperty to hoConnectionProperty
Set pvComObject of hoConnectionProperty to
vComConnectionProperty

Get ComName of hoConnectionProperty to lsTableProperties
[iTableItem-1].lsCrystalConnectionProperties[iCPItem-1].sName
Get ComValue of hoConnectionProperty to lsTableProperties
[iTableItem-1].lsCrystalConnectionProperties[iCPItem-1].sValue
Get ComDescription of hoConnectionProperty to
lsTableProperties[iTableItem-1].lsCrystalConnectionProperties[iCPItem-
1].sDescription

Send ReleaseComObject of hoConnectionProperty
Send destroy of hoConnectionProperty

Loop

Send releaseComObject of hoConnectionProperties
Send destroy of hoConnectionProperties
Loop
End_Procedure

I did enumerate all connection properties to se what I could be missing.
It showed only one property called "Data File" that contained the full
path and filename of the dbf file. So I guessed upon that changing the
Data File property would be the right way to go

// Sets the location for the DBF file.
Procedure Set DBFLocation Handle hoTable String sDBFFile
Variant vComConnectionProperties vComConnectionProperty
Handle hoConnectionProperties hoConnectionProperty

Get Create of hoTable U_cCrystalConnectionProperties to
hoConnectionProperties
Get ComConnectionProperties of hoTable to
vComConnectionProperties
Set pvComObject of hoConnectionProperties to
vComConnectionProperties
Get ComItem of hoConnectionProperties "Data File" to
vComConnectionProperty
Get Create of hoConnectionProperties U_cCrystalConnectionProperty
to hoConnectionProperty
Set pvComObject of hoConnectionProperty to vComConnectionProperty

Set ComValue of hoConnectionProperty to sDBFFile

Send ReleaseComObject of hoConnectionProperty
Send destroy of hoConnectionProperty
Send ReleaseComObject of hoConnectionProperties
Send destroy of hoConnectionProperties
End_Procedure


Set DBFLocation hTableObj[0] to "D:\firstfile.dbf"
Set DBFLocation hTableObj[1] to "D:\secondfile.dbf"

…but it gave exactly the same error as before.


--
Regards,
Allan Kim Eriksen
Programmer/systemconsolent

Nordteam Gruppen Aps
Denmark

Allan Greis Eriksen
2-Mar-2006, 05:03 AM
"David Martinko" <RedeemedSoftware@Hotmail.com> wrote in
news:PKOHaaVPGHA.540@dacmail.dataaccess.com:

> Try only setting the connection properties for the first table, and
> then just the location for the others DLL and stuff for the other
> tables. I also got errors when attempting to create the database
> connection when it already existed in another table.
>

I'm not sure what your are saying? If there is only one table in a report
it workes just fine changing location of the table. But if there are more
than one table I can't change the second table eventhough the connection
test is okay. Im not trying to create a new connection just change the
location of the existing tables in the report. Are there different dll's
that I need to be aware of?

--
Regards,
Allan Kim Eriksen
Programmer/systemconsolent

Nordteam Gruppen Aps
Denmark

David Martinko
2-Mar-2006, 07:57 AM
I was speaking the same thing you were.. changing the table location.

1) Are you just changing the location, same type of database, just a
different location?

When use SQL, It seems as though I only needed to establish the
ComBufferConnectString once. I set it for the first table and all other
tables followed.

If you look at the structure of your tables, you will see that there is one
connection to the database and then each table is listed under it.

Try setting the location only for the first table and see if your report
just works.

--
David Martinko
248-535-7495
Tracker Systems, Inc.
Redeemed Software
Redeemed Hosting
www.trackersys.com
www.redeemedsoftware.com
www.redeemedhosting.com
Proud member of the Northeast DataFlex Consortium: (NEDC)
www.NEDataFlex.com

"Allan Kim Eriksen" <ake@nordteam.dk> wrote in message
news:Xns977A708575EAAAllanKimEriksen@192.245.64.24 0...
"David Martinko" <RedeemedSoftware@Hotmail.com> wrote in
news:PKOHaaVPGHA.540@dacmail.dataaccess.com:

> Try only setting the connection properties for the first table, and
> then just the location for the others DLL and stuff for the other
> tables. I also got errors when attempting to create the database
> connection when it already existed in another table.
>

I'm not sure what your are saying? If there is only one table in a report
it workes just fine changing location of the table. But if there are more
than one table I can't change the second table eventhough the connection
test is okay. Im not trying to create a new connection just change the
location of the existing tables in the report. Are there different dll's
that I need to be aware of?

--
Regards,
Allan Kim Eriksen
Programmer/systemconsolent

Nordteam Gruppen Aps
Denmark

Allan Greis Eriksen
3-Mar-2006, 04:31 AM
Hi David

Thanks for trying to help, and understand what your are saying. If I only
had one source that would work, but I have more that one source/table (se
attached pic. and I hope that works :). That's the way the xBase
connection works.

As I mentioned before if there are only one table to set location for, it
works all right.

The wierd part is that I AM able to change the location of the second
source/tabel, because the connetion test does return true. But when I run
the report for expot it fails (also if I try to just view the record).


--
Regards,
Allan Kim Eriksen
Programmer/systemconsolent

Nordteam Gruppen Aps
Denmark

David Martinko
3-Mar-2006, 12:57 PM
Ok, so based on the screen shot you provided... you should be setting the
ComBufferConnectString for each datafile.

Try this:
Set the location of the first table. Close the report. Open the report. Set
the location of the next table. and repeat for all tables.

--
David Martinko
248-535-7495
Tracker Systems, Inc.
Redeemed Software
Redeemed Hosting
www.trackersys.com
www.redeemedsoftware.com
www.redeemedhosting.com
Proud member of the Northeast DataFlex Consortium: (NEDC)
www.NEDataFlex.com

"Allan Kim Eriksen" <ake@nordteam.dk> wrote in message
news:Xns977B6B0F7A334AllanKimEriksen@192.245.64.24 0...
Hi David

Thanks for trying to help, and understand what your are saying. If I only
had one source that would work, but I have more that one source/table (se
attached pic. and I hope that works :). That's the way the xBase
connection works.

As I mentioned before if there are only one table to set location for, it
works all right.

The wierd part is that I AM able to change the location of the second
source/tabel, because the connetion test does return true. But when I run
the report for expot it fails (also if I try to just view the record).


--
Regards,
Allan Kim Eriksen
Programmer/systemconsolent

Nordteam Gruppen Aps
Denmark

Allan Greis Eriksen
6-Mar-2006, 04:08 AM
"David Martinko" <RedeemedSoftware@Hotmail.com> wrote in
news:GR5YFwuPGHA.2932@dacmail.dataaccess.com:

> Ok, so based on the screen shot you provided... you should be setting
> the ComBufferConnectString for each datafile.
>
> Try this:
> Set the location of the first table. Close the report. Open the
> report. Set the location of the next table. and repeat for all tables.
>

Hi David.

I have tried just to change the second location and with the right
location for the first source saved in crystal, but that doesn't work
either. I haven't tried the ComBufferConnectString so I will try out that
one the next time. But for now I have told my collegaes that the report
have to be located at a specific location for this temporary application
to work. The old DOS Subst command is a great tool when things like this
happens ;) Then all the crystal reports are saved with the right
connection directly from crystal.
So for now I can't afford to spend more time on this strange issue. It
has to be something new to crystal since it worked just fine in crystal
8.5 and Visual Basic.


--
Regards,
Allan Kim Eriksen
Programmer/systemconsolent

Nordteam Gruppen Aps
Denmark