Salesforce SOQL from Crystal Reports

The Salesforce ODBC Driver extends the number of applications that you can use Salesforce SOQL from. In this blog, we describe how to run SOQL statements from Crystal Reports by using our ODBC driver.

To get started:

Before you can use the Salesforce.com ODBC Driver to connect your application to Salesforce.com, you need to configure an ODBC data source. An ODBC data source stores the connection details for the target database (e.g. Salesforce.com) and the ODBC driver that is required to connect to it (e.g. the Salesforce.com ODBC driver).

  1. Start ODBC Administrator. To do this, in the Windows Run dialog box, type:
    %windir%\syswow64\odbcad32.exe
  2. In the ODBC Administrator, choose the System DSN tab, and then choose Add.
  3. In the Create New Data Source dialog box, choose Easysoft Salesforce SOQL ODBC Driver, and then choose Finish.
  4. Complete the Easysoft Salesforce SOQL ODBC Driver DSN Setup dialog box:
    Setting Value
    DSN Salesforce.com
    User Name The name of your Salesforce.com user. For example, myuser@mydomain.com.
    Password The password for your Salesforce.com user.
    Token The security token for your Salesforce.com user, if required.

    To find out whether you need to supply a security token, choose the Test button. If the connection attempt fails with an error which contains LOGIN_MUST_USE_SECURITY_TOKEN, you need to supply one.

    Salesforce.com emails the security token to the email address associated with your Salesforce.com user account. If you have not received a security token, you can regenerate it. Salesforce.com will then email the new security token to you. To regenerate your security token, log in to Salesforce.com and then choose Setup from the user menu. Search for "security token" in the Quick Find box. Click Reset Security Token in the Reset Security Token page. When you receive the token in your email client, copy it and then paste it into the Token field.

  5. Use the Test button to verify that you can successfully connect to Salesforce.com.

Using Salesforce SOQL from Crystal Reports

Using the Salesforce ODBC driver to access Salesforce data from Crystal Reports:

  1. In Crystal Reports, create a new report.
  2. In the Standard Report Creation Wizard, in the Available Data Sources pane, expand the Create New Connection list.
  3. Expand the ODBC (RDO) list.
  4. In the ODBC (RDO) dialog box, in the Data Source Name list, choose your Salesforce.com ODBC data source. Choose Finish.
  5. Select the tables that you want include in your report, and then choose Next.
  6. Progress the Wizard to select the fields and fields that you want to include in your report.
  7. Click Finish to generate the report based on the Salesforce.com data.

Using the Salesforce ODBC driver to access Salesforce data from Crystal Reports by using pass-through SQL:

  1. In Crystal Reports, create a new report.
  2. In the Database Expert dialog box, expand your Salesforce.com data source under My Connections.
  3. Double-click Add Command.
  4. In the Add Command To Report dialog box, enter:
    SELECT Account.Name, (SELECT Contact.LastName FROM Account.Contacts)
    FROM Account
  5. Use the OK button to return to Crystal Reports.
  6. In the Field Explorer pane, expand Command under Database Fields. You should see, Name and LastName. Drag these fields to the Report Details section.
  7. On the View menu, choose Preview Sample to display the records.