修改 GBASE南大通用Server 数据

2023-12-20 08:01:06

通过?GBASE南大通用?ADO.NET 接口修改?GBASE南大通用Server 数据需要下面的步骤:

1) 使用GBASE南大通用Connection 创建数据库连接对象

2) 使用GBASE南大通用Command 创建命令对象

3) 使用连接对象打开连接

4) 设置命令对象的 CommandText 属性,指明 SQL 修改语句(Insert 或Delete 或 Update),并关联连接对象

5) 调用 GBaseCommand 的 ExecuteNonQuery 方法执行 SQL 修改语句

6) 关闭数据库连接

下面的例子将展示如何打开数据库连接,向 test 表插入一条数据,可以使

用同样的步骤 Delete 或者 Update 数据。

C# 示例:

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Diagnostics;

using System.Data;

using GBase.Data.GBaseClient;

namespace UsingAdoNet

{

class Program

{

static void Main(string[] args)

{

String _ConnStr = "server=192.168.5.41;user

id=root;password=1;database=test;pooling=false";

using (GBaseConnection _Conn = new

GBaseConnection(_ConnStr))

{

try

{

tring _CmdText = "insert into

`test`(`varchar_column`) values(‘varchar_value’) ";

GBaseCommand _Cmd = new GBaseCommand(_CmdText,

_Conn);

_Conn.Open();

_Cmd.ExecuteNonQuery();

}

catch (GBaseException ex)

{

Console.WriteLine(ex.StackTrace);

}

finally

{

if( _Conn != null )

_Conn.Close();

}

}

}

}

}

文章来源:https://blog.csdn.net/weixin_47390342/article/details/135086523
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。