Data Connectivity
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Data Connectivity
Message Icon Topic: CR 2008, SQL 2005 and Excel 2007 Post Reply Post New Topic
Author Message
TonyM70
Newbie
Newbie


Joined: 06 Apr 2011
Online Status: Offline
Posts: 9
Quote TonyM70 Replybullet Topic: CR 2008, SQL 2005 and Excel 2007
    Posted: 16 Oct 2012 at 4:26am
I have a valid SQL statement that has gathers records from 2 data sources, SQL tables and 2007 excel spreadsheet.

The intent was to utilize SQL statement in CR Command via existing SQL connection to db that contains the source tables.

However, when pasted in the CR command errors are generated - "Failed to retrieve data from database.... Native Error 7399" and "Failed to retrieve data from database.... Native Error 7303". These errors also reference the Microsoft Jet 4.0 provider.

I have found scads of web posts that discuss issues with file permissions, 64 vs 32 bit support of Jet 4.0 provider and Excel 2007/2010 compatibility. I believe I have ruled out these possible conflicts.

The SQL statement is attached below. I am seeking guidance on how to proceed. Any insight is greatly appreciated.

SELECT *
FROM

(SELECT
          Document,
          Packlist,
          Customer_PO
   FROM Production.dbo.Invoice_Detail) ID
JOIN
(SELECT
          Document,
          Customer,
          Document_Date,
          Open_Invoice_Amt
   FROM Production.dbo.Invoice_Header) IH
ON     ID.Document = IH.Document

WHERE Customer like '12567%' and IH.Open_Invoice_Amt <> 0 and Packlist not in (SELECT [InvoiceNumber] FROM OPENDATASOURCE('Microsoft.Jet.OLEDB.4.0','Data Source=S:\Barb\export1.xls;Extended Properties=EXCEL 8.0')...[export2$] E JOIN Production.dbo.Invoice_Detail ID ON E.InvoiceNumber = ID.Packlist)
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3702
Quote hilfy Replybullet Posted: 16 Oct 2012 at 5:25am
Crystal 2008 will not read data from Excel 2007.
 
-Dell
IP IP Logged
TonyM70
Newbie
Newbie


Joined: 06 Apr 2011
Online Status: Offline
Posts: 9
Quote TonyM70 Replybullet Posted: 16 Oct 2012 at 7:41am
Hilfy - thanks much for the response..... 
 
couple of questions:
 
CR 2008 cannot read Excel 2007 regardless of file format (i.e. saved as 97-2003)?
 
will upgrade of CR resolve this or is this an MS office/windows issue?
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3702
Quote hilfy Replybullet Posted: 16 Oct 2012 at 8:28am
It MUST be saved as 97-2003, in which case it's not in Excel 2007 format.  When you say "Excel 2007" it is assumed that that's the format of the file, not necessarily the version of the software.
 
What type of connection are you using to connect to your SQL Server database?  I'm not sure whether the "OPENDATASOURCE" syntax will pass through to the database with an OLEDB connection and I'm pretty sure it won't work correctly with ODBC.  There are issues with both types of connections, but OLEDB usually has more features than ODBC.
 
Can you run the query in SQL Server Management Studio?  I would start there and make sure the query works directly against the database before putting it into Crystal and trying it there.
 
-Dell
IP IP Logged
TonyM70
Newbie
Newbie


Joined: 06 Apr 2011
Online Status: Offline
Posts: 9
Quote TonyM70 Replybullet Posted: 16 Oct 2012 at 8:59am
yes - file is/was saved as 97-2003, sorry for the miscommunication.

yes - the query was developed and debugged in SSMS.

connection attempted was OLEDB (ADO) provider. I can also confirm no success with ODBC.

I'm having some difficulty understanding the following: if I create an Access/Excel (DAO) connection directly to the .xls file it is successful with no errors. This is true even when two connections are made - one to SQL db and the other to .xls.
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3702
Quote hilfy Replybullet Posted: 16 Oct 2012 at 10:58am

It is because you are trying to connect through a SQL Server connection, not an Access/Excel DAO connection.  While SMS will allow this, there is something in the OLEDB middle-ware that doesn't understand this type of connection and so your query is causing an error.

Here's what I would do (if Crystal will let you...):

1.  Add the data from SQL Server under one connection and the data from Excel under another.

2.  Left Outer Join from the SQL Server data to the Excel data.

3.  In your selection criteria, do something like the following formula:

 
IsNull({ExcelTable.InvoiceNumber})
 
This should get you all of the data in the table that's not in the Excel file.  If this doesn't work, you'll have to look at uploading the Excel to a table in the database and working from there.
 
-Dell
IP IP Logged
TonyM70
Newbie
Newbie


Joined: 06 Apr 2011
Online Status: Offline
Posts: 9
Quote TonyM70 Replybullet Posted: 17 Oct 2012 at 4:47am
Thanks for the explanation - it is greatly appreciated.

I had started down the road of dual connections but was not linking correctly and did not consider the need for additional selection criteria. Looks like this was the missing piece!

Thank you for your time and input!
IP IP Logged
Post Reply Post New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum



This page was generated in 0.031 seconds.