Open Source RDBMS - Seamless, Scalable, Stable and Free

한국어 | Login |Register

Connection String


The first thing you need to know in order to open a CUBRID connection from a.NET application is how to build the database connection string.

The format of the CUBRID ADO.NETconnection string is:

ConnectionString = "server=<server address>;database=<database name>;port=<port number to use for connection to broker>;user=<user name>;password=<user password>;autocommit=<auto-commit mode of database to be connected>;"

Notes:

  • All parameters are mandatory, except for the (CUBRID broker) port number.
  • If you don't specify the broker port number, the default value assumed is 33000.
  • The autocommit is only used to turn ON/OFF of auto-commit mode. It has one of the following value: 0 or 1, the default value assumed is 1, auto-commit mode is ON.

Examples

  • Connect to a local server, using the default demodb database:
    ConnectionString = "server=127.0.0.1;database=demodb;port=33000;user=public;password="
  • Connect to a local server, using the default demodb database and turn off auto-commit:
    ConnectionString = "server=127.0.0.1;database=demodb;port=33000;user=public;password=;autocommit=0"
  • Connect to a remote server, using the default demodb database, as user dba:
    ConnectionString = "server=10.50.88.1;database=demodb;user=public;password="
  • Connect to a remote server, using the default demodb database, as user dba, using password "secret":
    ConnectionString = "server=10.50.99.1;database=demodb;port=33000;user=public;password=secret"

As alternative, you can use the CubridConnectionStringBuilder class to build easily a connection string in the correct format. For example:

CUBRIDConnectionStringBuilder sb = new CUBRIDConnectionStringBuilder("localhost", "demodb", "public", "", "33000");
using (CUBRIDConnection conn = new CUBRIDConnection(sb.GetConnectionString()))
{
    conn.Open();
}

or:

CUBRIDConnectionStringBuilder sb = new CUBRIDConnectionStringBuilder();
sb.User = "public";
sb.Database = "demodb";
sb.Port = "33000";
sb.Server = "10.0.0.129";
sb.Password = "";
using (CUBRIDConnection conn = new CUBRIDConnection(sb.GetConnectionString()))
{
    conn.Open();
}
comments powered by Disqus
Page info
viewed 3533 times
translations ko en
Author
posted 2 years ago by
CUBRID
Contributors
updated last year by
View revisions
Share this article