日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > 数据库 >内容正文

数据库

CUBRID学习笔记 3 net连接数据库并使用cubrid教程示例

發(fā)布時間:2025/4/16 数据库 51 豆豆
生活随笔 收集整理的這篇文章主要介紹了 CUBRID学习笔记 3 net连接数据库并使用cubrid教程示例 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

接上文

數(shù)據(jù)庫安裝好后,也可以測試語句了.

下面我們用c#寫一個控制臺程序,連接數(shù)據(jù)庫,并讀取數(shù)據(jù).

一 下載驅(qū)動 ?net版的下?CUBRID ADO.NET Data Provider 9.3.0.0001.zip 這個就可以.解壓后里面有一個CUBRID.Data.dll

二 創(chuàng)建控制臺,添加對CUBRID.Data.dll的引用

三 寫代碼

如下

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();} } }

  結(jié)果如下:

?

?

其中?

AutoCommit 是否自動提交事務 我簡單的理解 :如果不手動用事務的話 ,可以開啟.如果手動控制事務的話 ,關閉它 . 然后 手動提交 COMMIT WORK; SetAutoCommit的說明如下 :


sql語句中: AUTOCOMMIT IS OFF
CCI_DEFAULT_AUTOCOMMIT ??

CCI_DEFAULT_AUTOCOMMIT?is a parameter used to configure whether to make application implemented in CCI interface or CCI-based interface such as PHP, ODBC, OLE DB, Perl, Python, and Ruby commit automatically. The default value is?ON. This parameter does not affect applications implemented in JDBC. In case of using ODBC, malfunction can occur if this parameter is?ON; you must set it to?OFF, in this case.

If the?CCI_DEFAULT_AUTOCOMMIT?parameter value is?OFF, the broker application server (CAS) process is occupied until the transaction is terminated. Therefore, it is recommended to execute commit after completing fetch when executing the?SELECTstatement.

c#,net,cubrid,教程,學習,筆記歡迎轉(zhuǎn)載 ,轉(zhuǎn)載時請保留作者信息。本文版權(quán)歸本人所有,如有任何問題,請與我聯(lián)系wang2650@sohu.com 。 過錯

Note?The?CCI_DEFAULT_AUTOCOMMIT?parameter has been supported from 2008 R4.0, and the default value is?OFF?for the version. Therefore, if you use CUBRID 2008 R4.1 or later versions and want to keep the configuration?OFF, you should manually change it to?OFF?to avoid auto-commit of unexpected transaction.

更詳細的文檔?http://www.cubrid.org/wiki_apis/entry/ado-net-driver-development-notes ?最新版是9.3了,這個文章是8的.

如果感興趣可以看源碼吧

?

轉(zhuǎn)載于:https://www.cnblogs.com/wang2650/p/5282848.html

《新程序員》:云原生和全面數(shù)字化實踐50位技術專家共同創(chuàng)作,文字、視頻、音頻交互閱讀

總結(jié)

以上是生活随笔為你收集整理的CUBRID学习笔记 3 net连接数据库并使用cubrid教程示例的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。