9.3.2 Setup Database Connection

Summary

The database used in this tutorial has been set up on Microsoft Azure.

This tutorial will cover how to build the connection to a(n) SQL server with three different methods — the Windows 'Data Link Properties', a Connection String, and the ODBC driver.
The ODBC driver offers the fastest connection performance, but it requires the ODBC driver to be installed on your system.
The procedure is based on Origin 2025b.

What you will learn

This tutorial will show you how to:

  • Create a database connection with Windows Data Link Properties
  • Create an SQL Query in the SQL Editor and import data.
  • Get a Connection String from Origin.
  • Use a Connection String to create a database connection.
  • Create a database connection with the ODBC driver.

Connection Methods

Create a Connection with the Windows 'Data Link Properties' dialog

  1. Start a new worksheet. Select from menu Data: Connect to Database: New.... In the Database Connector dialog, select Windows "Data Link Properties" dialog and click OK.
  2. NewDB1.png

    NewDB DLP.png

  3. Select Microsoft OLE DB Provider for SQL Server and click Next.
    DLP dialog provider.png
  4. Create the connection to a sample database. Specify the server information, log-in user name, and password.
    Server name=olab.DATABASE.windows.net
    USER Name=Olabts
    Password=Origin@2024

    DLP dialog connection.png

    Click the Test Connection button to make sure the connection is successful.

    Make sure to check Allow saving password to prevent additional password prompts.

  5. Select a database by clicking on the dropdown menu and selecting sample1.
    Click the OK button to open the SQL Editor dialog.
  6. All tables in the database are listed in the left panel.
    NewDB4.png
    You can extract data by writing your own SQL query or create a query by double-clicking the nodes in the left panel. Click OK to import the data.
    SQL Editor import.gif

    Get Connection String

    1. Click the Database Connector icon and select SQL Editor... to reopen the SQL Editor dialog.
      Reopen SQL editor.gif
    2. Select menu File: Show Connection String. The connection string will show at the Message panel below. You can use this connection string in the next step to create the connection.
      GetConnectionString.png

    Create a Connection with a Connection String

    1. Start a new worksheet. Select from menu Data: Connect to Database: New.... In the Database Connector dialog, select Connection String and click OK.
      NewDB CS.png
    2. Paste your connection string into the Connection String Editor. You can use the one provided in the previous section or an existing connection string of your own. For this tutorial, we'll use the connection string obtained earlier.
      Provider=SQLOLEDB.1;Password=Origin@2024;Persist Security Info=TRUE;USER ID=olabts;Initial Catalog=sample1;DATA SOURCE=olab.DATABASE.windows.net

      ConnectionStringEditor.png

      Click the Test button to make sure the connection is successful.

    3. Click the OK button to open the SQL Editor dialog to query and import.

    Create a Connection with the ODBC driver

    The ODBC driver method requires you to have the ODBC driver installed. You can download and install the latest driver here.

    1. Start a new worksheet. Select from menu Data: Connect to Database: New.... In the Database Connector dialog, select ODBC driver and click OK.
    2. NewDB2.png

    3. Create the connection to a sample database. Specify the server information, including the log-in user name and password with the settings below:
      Server Driver=ODBC Driver 18 FOR SQL Server
      Server=olab.DATABASE.windows.net
      Port=1433
      USER Name=Olabts
      Password=Origin@2024

      NewDB3.png

      Click the Test button to make sure the connection is successful.

      If it fails to connect to the database, go to this page to download and install the latest ODBC SQL driver.

    4. Click the NewDB5.png button to the right of the Database entry and make sure database sample1 shows.
    5. Click the OK button to open the SQL Editor dialog to query and import.