Cubrid Learn notes 3 net connect a database and use

Source: Internet
Author: User
Tags odbc

Connect to the above

After the database is installed, you can also test the statement.

Below we write a console program in C #, connect to the database, and read the data.

Download the drive NET version of the next Cubrid ADO Provider 9.3.0.0001.zip This can be. After the decompression there is a CUBRID.Data.dll

Two create the console, add a reference to the CUBRID.Data.dll

Three-write code

As follows

Using system;using system.collections.generic;using system.linq;using system.text;using CUBRID. Data.cubridclient;namespace Cubridtest {class Program {static void Main (string[] args) {Cubrid.        Data.CUBRIDClient.CUBRIDConnectionStringBuilder sb = new Cubridconnectionstringbuilder (); Sb.        User = "public"; Sb.        Database = "Demodb"; Sb.        Port = "33000"; Sb.        Server = "192.168.2.156"; Sb.        Password = ""; using (cubridconnection conn = new Cubridconnection (sb.) GetConnectionString ())) {Conn.            Open (); Conn.            Setautocommit (FALSE);  using (cubridcommand cmd = new Cubridcommand ("SELECT * FROM athlete limit 1,10", conn)) {using (System.Data.Common.DbDataReader reader = cmd.) ExecuteReader ()) {while (reader. Read ()) {Console.WriteLine (reader[0].      ToString () + ";");}}}  } console.readkey (); }}}

The results are as follows:

which

Setautocommit's instructions are as follows
Cci_default_autocommit

Cci_default_autocommit is a parameter used to configure whether to make application implemented in CCI interface or CCI-BA Sed interface such as PHP, ODBC, OLE DB, Perl, Python, and Ruby commit automatically. The default value is on . This parameter does isn't affect applications implemented in JDBC. In case of using ODBC, the malfunction can occur if this parameter are on; must set it to OFF

If the Cci_default_autocommit parameter value is OFF, the broker Application Server (CAS) process is occupied unti L The transaction is terminated. Therefore, it's recommended to execute commit after completing fetch when executing the selectstatement.

Note The Cci_default_autocommit parameter have been supported from R4.0, and the DEFAULT value are OFF for the Version. Therefore, if you use Cubrid-R4.1 or later versions and want to keep the configuration OFF, you should manually C Hange it to OFF to avoid auto-commit of unexpected transaction.

More detailed documentation http://www.cubrid.org/wiki_apis/entry/ado-net-driver-development-notes the latest version is 9.3, this article is 8.

If you're interested, look at the source.

Cubrid Learn notes 3 net connect a database and use

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.