CUBRID学习笔记 36 在net中添加多行记录
using System.Data.Common; using CUBRID.Data.CUBRIDClient; namespace Sample
{
class Add_MultipleRows
{
/* conection string */
/* Please modify before using. */
static readonly string _connString = "server=127.0.0.1;database=demodb;port=33000;user=public;password="; public void using_sql()
{
using (CUBRIDConnection conn = new CUBRIDConnection())
{
conn.ConnectionString = Add_MultipleRows._connString;
conn.Open(); string sql = "drop table if exists table11;";
try
{
using (CUBRIDCommand cmd = new CUBRIDCommand(sql, conn))
{
cmd.ExecuteNonQuery();
}
}
catch { } /* create new table */
sql = "create table table11(a string , b string, c string);";
using (CUBRIDCommand cmd = new CUBRIDCommand(sql, conn))
{
cmd.ExecuteNonQuery();
} /* insert multi rows values */
sql = "insert into table11 (a, b, c) values ('1', '2','3'),('a', 'b','c'),('!', '@', '#');";
using (CUBRIDCommand cmd = new CUBRIDCommand(sql, conn))
{
cmd.ExecuteNonQuery();
} /* verify count */
sql = "select count(*) from table11";
using (CUBRIDCommand cmd = new CUBRIDCommand(sql, conn))
{
using (DbDataReader reader = cmd.ExecuteReader())
{
reader.Read();
if (reader.GetInt32(0) == 3)
; // do something;
}
} sql = "drop table11;";
using (CUBRIDCommand cmd = new CUBRIDCommand(sql, conn))
{
cmd.ExecuteNonQuery();
}
}
}
}
}
上面的代码是正常的体位.
下面的是批量提交.主要使用了BatchExecuteNoQuery 这个很有情趣的工具
using System.Data.Common; using CUBRID.Data.CUBRIDClient; namespace Sample
{
class Add_MultipleRows
{
/* conection string */
/* Please modify before using. */
static readonly string _connString = "server=127.0.0.1;database=demodb;port=33000;user=public;password="; public void using_cubrid_connection()
{
using (CUBRIDConnection conn = new CUBRIDConnection())
{
conn.ConnectionString = Add_MultipleRows._connString;
conn.Open(); string[] sqls = {
"drop table if exists table11;",
"create table table11(a string , b string, c string);",
"insert into table11 (a, b, c) values ('1', '2','3');",
"insert into table11 (a, b, c) values ('a', 'b','c')",
"insert into table11 (a, b, c) values ('!', '@', '#');"
};
conn.BatchExecuteNoQuery(sqls); /* verify count */
string sql = "select count(*) from table11";
using (CUBRIDCommand cmd = new CUBRIDCommand(sql, conn))
{
using (DbDataReader reader = cmd.ExecuteReader())
{
reader.Read();
if (reader.GetInt32(0) == 3)
; // do something;
}
} sql = "drop table11;";
using (CUBRIDCommand cmd = new CUBRIDCommand(sql, conn))
{
cmd.ExecuteNonQuery();
}
}
}
}
}
CUBRID学习笔记 36 在net中添加多行记录的更多相关文章
- bootstrap学习笔记之为导航条添加标题、二级菜单及状态 http://www.imooc.com/code/3120
为导航条添加标题.二级菜单及状态 加入导航条标题 在Web页面制作中,常常在菜单前面都会有一个标题(文字字号比其它文字稍大一些),其实在Bootstrap框架也为大家做了这方面考虑,其通过" ...
- Android学习笔记36:使用SQLite方式存储数据
在Android中一共提供了5种数据存储方式,分别为: (1)Files:通过FileInputStream和FileOutputStream对文件进行操作.具体使用方法可以参阅博文<Andro ...
- 【转】Pandas学习笔记(三)修改&添加值
Pandas学习笔记系列: Pandas学习笔记(一)基本介绍 Pandas学习笔记(二)选择数据 Pandas学习笔记(三)修改&添加值 Pandas学习笔记(四)处理丢失值 Pandas学 ...
- C# 往Datatable中添加新行的步骤
以一个实例说明 //录入年份绑定 public void YearList(FineUIPro.DropDownList ddlYear) { //年份从15年到当前年//起止年份 ; int yea ...
- Java 在Word中添加多行图片水印
Word中设置水印效果时,不论是文本水印或者是图片水印都只能添加单个文字或者图片到Word页面,效果比较单一,本文通过Java代码示例介绍如何在页面中添加多行图片水印效果,即水印效果以多个图片平铺到页 ...
- GridView内按钮Click获取记录主键值 在GridView控件中,每行记录内会放置一个铵钮,当用
在GridView控件中,每行记录内会放置一个铵钮,当用户点击这个铵钮时,获取当笔记录的主键值.可看演示(是一个gif动画,重新播放尝试刷新网页): 实现这个功能,你需要为GridView控件设置Da ...
- [原创]java WEB学习笔记36:Java Bean 概述,及在JSP 中的使用,原理
本博客为原创:综合 尚硅谷(http://www.atguigu.com)的系统教程(深表感谢)和 网络上的现有资源(博客,文档,图书等),资源的出处我会标明 本博客的目的:①总结自己的学习过程,相当 ...
- CUBRID学习笔记 3 net连接数据库并使用cubrid教程示例
接上文 数据库安装好后,也可以测试语句了. 下面我们用c#写一个控制台程序,连接数据库,并读取数据. 一 下载驱动 net版的下 CUBRID ADO.NET Data Provider 9.3.0 ...
- CUBRID学习笔记 48查询优化
cubrid的中sql查询语法 查询优化 c#,net,cubrid,教程,学习,笔记欢迎转载 ,转载时请保留作者信息.本文版权归本人所有,如有任何问题,请与我联系wang2650@sohu.com ...
随机推荐
- Ubuntu 安装 “宋体,微软雅黑,WPS Office的symbol、wingdings、wingdings 2、wingdings 3、webding字体,Consolas雅黑混合版编程字体” 等 Windows 7 下的字体(转)
Windows平台下,"宋体"."微软雅黑"."Courier New(编程字体)"用的比较多,看的也习惯了.那如何在 Ubuntu下也安装 ...
- ss 公共代理的必要设置(转)
转: https://gist.github.com/fqrouter/95c037f9a3ba196fd4dd 本文只关注于确保ss服务还“活着”,如果你希望让其跑得更快,请参考 https://g ...
- Bootstrap之Carousel问题
一.不能自动播放的解决办法 1.默认使用Bootstrap的Carousel组件,只需要加上 data-ride="carousel" 就可以实现自动播放了.无需使用初始化的js函 ...
- JSP/Servlet 中的汉字编码问题
JSP/Servlet 中的汉字编码问题 1.问题的起源 每个国家(或区域)都规定了计算机信息交换用的字符编码集,如美国的 ASCII,中国的 GB2312 -80,日本的 JIS 等,作为该国家/区 ...
- python3.4 or 3.x xlwt replaced with xlwt-future
Q:最近在使用python3.4处理一些生物信息数据,需要将内容保存到excel中,但是,但是,发现xlwt不能再3.4中使用,即使安装也安装不成功. 由于xlwt不兼容python3.4(x),不必 ...
- 【转载】使用barman备份PostgreSQL
什么是barman Barman (备份和恢复管理器) 是 PostgreSQL 数据库服务器中非常方便的备份和恢复工具,允许远程备份多个服务器,允许从一个备份集中一个命令就恢复数据库.同时还可以对多 ...
- SQL中join的用法
关于sql语句中的连接(join)关键字,是较为常用而又不太容易理解的关键字,下面这个例子给出了一个简单的解释 --建表table1,table2:create table table1(id int ...
- 修改sql2005字段
alter table 表名 add 字段名 数据类型 default 默认值 增加:alter table AdCategory ADD SEOTitleNo varchar(50); 删除:ALT ...
- Drainage Ditches 分类: POJ 图论 2015-07-29 15:01 7人阅读 评论(0) 收藏
Drainage Ditches Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 62016 Accepted: 23808 De ...
- Unity-Animator深入系列---deltaPosition&deltaRotation
回到 Animator深入系列总目录 官方文档给出的信息非常含糊 Gets the avatar delta position for the last evaluated frame. 测试了一下, ...