How To : Connecting to an SQL Database

Page Status: Beta

Back to Concepts and HOW TOs

Contents

[edit] Description

This document describes how to add an SQL project to a solution and connect the project to a MySQL or PostgreSQL database. You also have the option to have a MySQL sandbox automatically provisioned for testing.

[edit] Prerequisites

Introduction to Bungee Builder
Introduction to Working with SQL Databases

[edit] Whitelisting Your Hosted Database

If you want to connect to a MySQL or PostgreSQL database hosted on the web, you will need to have the DNS name %.bungeegrid.com whitelisted to allow connection.

[edit] Procedure

To add and connect an SQL project:

  1. In the Solution Explorer, right-click on the solution and select Add Project.
  2. In the dialog box that's displayed, do the following:
    1. Select SQL Project. Click Next.
    2. In Name, type a name for the project (the default is SQL Project).
    3. Select MySQL, PostgreSQL or Sandbox (MySQL Database)
    4. If you chose MySQL, under Settings, configure this project to connect to a database.
      1. For Host, type the URL where your database is being hosted (do not include the http://).
      2. For Database, type the name of the database to which you want to connect.
      3. For User, type the username for connecting to this database.
      4. For Password, type the password for connecting to this database.
      5. For Port, type the port number for the port you want to use to connect to this database (MySQL uses 3306 by default).
      6. (Optional) Click Test Connection to test the settings you have entered before you add the project.
      7. Click Done.
    5. If you chose PostgreSQL, under Settings, configure this project to connect to a database.
      1. For Host, type the URL where your database is being hosted (do not include the http://).
      2. For Database, type the name of the database to which you want to connect.
      3. For User, type the username for connecting to this database.
      4. For Password, type the password for connecting to this database.
      5. For Port, type the port number of the port you want to use to connect to this database (PostgreSQL uses 5432 by default).
      6. (Optional) Click Test Connection to test the settings you have entered before you add the project.
      7. Click Done.
    6. If you chose Sandbox, under Settings, all the settings are automatically set for you. Click OK.
  3. The project is added to the solution.

To interact with the SQL database at design time:

  1. In the Solution Explorer, expand your SQL project.
  2. Expand MySQL or Postgres, depending on which type of database your project is connected to.
  3. For a MySQL database, MySQL Databases, shows all the databases available in the current connection.
  4. For a Postgres database, the Database name is shown.
  5. Double-click SQL Console. This opens the SQL Console in the Design Editor.
    In the SQL Console, you can execute sql queries on your database.
  6. Config allows you to change the configuration setting of the connection for the project. 

[edit] Error Handling

 

[edit] Examples

 

[edit] Next Steps

Creating a Class to Contain Row Data from an SQL Table
Logging in to an SQL Database
Adding CRUD Operations to a Class
Using SQL Query Escaping
Debugging SQL
Adding a Class to a Project
Adding a Function to a Class
Adding a Field to a Class
Adding a Form to a Class

[edit] Tags

    Copyright © 2005 - 2007 Bungee Labs. All rights reserved.