Open Source RDBMS - Seamless, Scalable, Stable and Free

한국어 | Login |Register

How to use the CUBRID ADO.NET Data Provider?


Create a new project

Open Microsoft VS.net 2008, select File->New->Project…. In the new project dialog, select Other Languages-> Visual C# and project type is Console Application. Input project name: Sample, press OK.

new-project.png

Add Refernces

In solution explorer, right click on the References, in the pop-up menu, select Add Reference….

Add References.png

In the popup dialog select Browser page, open the CUBRID ADO.NET Data Provider installation directory, and select CUBRID.Data.dll.

select_dll.png

How to connect to CUBRID Database server?

Use CUBRIDConnection class to connect to the database server. In the source file add following code:

using CUBRID.Data.CUBRIDClient;

C# Sample

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.Common;
using CUBRID.Data.CUBRIDClient;
 
namespace Sample
{
    class DBTest
    {
        static readonly string _connString = "server=127.0.0.1;database=demodb;port=33000;user=public;password=";
        /*
         * Connect to CUBRID DB server
         */
        public void ConnectDB()
        {
            /* create a new CUBRIDConnection instance */
            using (CUBRIDConnection conn = new CUBRIDConnection())
            {
                try
                {
                    /* set the connection string */
                    conn.ConnectionString = _connString;
                    /* connect to db server */
                    conn.Open();
                }
                catch (Exception exp)
                {
                    Console.WriteLine(exp.Message);
                }
            }
        }
    }
}
comments powered by Disqus
Page info
viewed 1151 times
translations en
Author
posted last year by
kevinyang
Contributors
updated last year by
View revisions
Share this article