Establishing a Data Source Name

From Documentation
Jump to: navigation, search
This page contains changes which are not marked for translation.

Establishing a Data Source Name

Before you add a Connector to your page, you must create a Data Source Name or set up a Custom connection. A Data Source Name is a way for Windows to find your database. You register your database with Windows to create a data source.

You can use a data source to connect to a variety of database management systems, such as MSAccess. If using a data source, you must register your database as an ODBC data source on your computer before building your database connector. If you re testing the application by publishing it to a separate computer, repeat these steps to register the database on that machine too.

Note: The instructions below illustrate how to register a database on a computer running Microsoft Windows XP. If you are using a different operating system, refer to your operating system's Help for information about registering a database.

Registering a Microsoft Access Database

  1. Open the Control Panel from the Windows Start, Settings menu.
  2. Double-click the Administrative tools icon.
  3. On the Administrative tools dialog, double-click the ODBC or ODBC (32 Bit) icon.

The ODBC Data Source Administrator opens.

Note: If you don't see this icon in the Control Panel window, download and install the Microsoft ODBC drivers from http://www.microsoft.com.

  1. Click the System DSN tab. Then click Add.

The Create New Data Source wizard opens.

  1. Select Microsoft Access Driver and click Finish.

The ODBC Setup dialog opens.

  1. Type the name of your data source in the Data Source Name field.
  2. In the Database fieldset, click Select.
  3. Navigate to the folder your database is stored in and select the file.
  4. Click OK to close the Select Database, ODBC Setup, and Data Source Administrator dialogs.

Registering Other Types of Databases

The process for connecting to other types of databases is similar. For example, if you have a MySQL database installed on your local machine, follow the following steps:

  1. Install MyODBC on your machine from http://www.mysql.com.
  2. Ensure that MySQL is running on your machine.
  3. Open the Control Panel from the Windows Start, Settings menu and doubleclick the ODBC or ODBC (32 Bit) icon.

The ODBC Data Source Administrator opens.

  1. Click the System DSN tab and then click Add.

The Create New Data Source wizard opens.

  1. Select MySQL ODBC Driver and click Finish.

The ODBC Setup dialog appears.

  1. Type the name of your data source in the Data Source Name field.
  2. Type "localhost" in the Server field.
  3. Enter your user name for this database in the User field. Consult your system administrator.
  4. Enter your password for this database in the Password field.
  5. Select the database from the select box.
  6. Click Test to confirm your information is correct.
  7. Click OK to close the Connector/ODBC, ODBC Setup, and Data Source Administrator dialogs.

Establishing a DSN Connection

Once you have registered and created a Data Source Name (DSN), you can add a connector so that your page can communicate with the database.

Warning: If you set a publish profile using a DSN connection, you need to make sure that the DSN also exists on the server to which you publish your site.

To set up a DSN database connection:

  1. Create a new connector by clicking the New Connector button within the Data Sources Properties panel.

If the Data Sources Properties panel is not visible: from the View menu, choose More Panels, then check the Data Sources option.

  1. Select the Database Connector option.
  2. Enter a name for the connector in the editable field, or keep the suggested name.
  3. Double-click the connector to open its properties editor.

The New Connection > Advanced dialog appears.

  1. From the Publish Profile(s) drop-down list, select the Publish Profile that the connection will use.

You could create multiple connection profiles when creating a database. If, for example, you are updating a database and want to publish it to a server where it can be tested before it's published to the Web, you could set up a connection profile for private testing and another for publishing to the Web.

If you have not yet created a publish profile, you can do this in Publish View by selecting Publish Settings from the Publish menu.

  1. From the Database Type drop-down list, select either an MS Access, MS SQL, and MySQL engine. A database engine is the part of the database system that stores and retrieves the data.
  2. Select the DSN Connection type.
  3. In the DSN field, specify the Data Source Name associated with the connection or use the Browse button to locate one. A Data Source Name (DSN) contains the information about a specific database that an Open Database Connectivity (ODBC) driver needs to connect to it.

If you click the Browse button, the Select Data Source dialog appears.

  1. In the Select Data Source dialog that appears, click the Machine Data Source tab and select the Data Source Name associated with the connection.
  2. Click OK.

The Connector ODBC 3.51 Data Setup dialog will appear, displaying the connection details.

  1. Click OK to close the Connector ODBC 3.51 Data Setup dialog.
  2. Now that you are back to the New Connection -Advanced dialog, click the Test button. You should have a successful connection. If you cannot establish a connection, you can create your database structure manually.

NetObjects Fusion

Setting a New Data Source from NetObjects Fusion

  1. If you want to create a new Data Source for this connection, click the Browse button from the New Connection - Advanced dialog.

The Select Data Source dialog appears.

  1. In the Select Data Source dialog that appears, click the Machine Data Source tab and then click New.
  2. In the Create New Data Source dialog that appears, choose the System Data Source option and then click Next.

Note: For Microsoft Windows Vista, the System Data Source option is available only from the Administrator account. If you are logged in with a User account having Administrator permissions, the System Data Source option will not be available.

  1. In the dialog that appears, choose MySQL ODBC 3.51 Driver from the list.
  2. Now, click Next and then click Finish. The Connector ODBC 3.51 Add Data Source Name dialog will appear.
  3. In theData Source Name field, specify a name for the data source.
  4. Type the short description of your data source in the Description field.
  5. Type the database server in the Server field.
  6. Enter your user name for this database in the User field. Consult your system administrator.
  7. Enter your password for this database in the Password field.
  8. Select the database from the drop-down list.
  9. Click Test to confirm your information is correct.
  10. Click OK to close the Connector/ODBC dialog.
  11. Now that you are back to the New Connection -Advanced dialog, click the Test button. You should have a successful connection. If you cannot establish a connection, you can create your database structure manually.

Establishing a Custom Connection

There are situations where you may not want to use a Data Source Name. For example, some hosting providers use systems that are not compatible with Data Sources. There are also some advanced configuration options available only by sing a custom connection.

The following process creates a custom connection to MySQL:

  1. In the New Connection > Advanced dialog, enter the network information for the server hosting the MySQL database. If the database is hosted on the local machine, enter "localhost".
  2. Select "MySQL" from the Database Type drop-down list.
  3. Enter the user name in the User field.
  4. Enter the user password in the Password field.
  5. Enter the database server in the Database Server field.
  6. Enter the name of the database in the Database field or select the database from the drop-down list.
  7. Specify a port in the Port field.
  8. Enter parameters in the Parameters field if required.
  9. Click Test to check your connection.

If the Test fails, it may be for one of the following reasons:

  • The database is not running on the host specified. Check to ensure that the database is created and running on the mentioned server.
  • The host specified is unreachable. Check to ensure that the machine specified in the Host field is on and reachable from your machine. Take into account that a database is a collection of tables; therefore at least one table within the database should be created.
  • The database specified in the Database field has not been created. Ensure that the database has been created on the running instance of MySQL on the host specified in the Host field.
  • The security information is not correct. Ensure that the User and Password fields are correct for your database.
  • You do not have permission to connect to the specified database. Ensure that you have permissions to connect to the database. Consult your system administrator.

Note: It is necessary to have permissions on the tables in the database (select, insert, update, delete, create, drop). Unless these permissions are granted, it is possible that errors appear when connecting to the database, even if the connectivity test is valid.