GBASE南大通用数据库如何修改GBase Server数据

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

 1) 使用 GBaseConnection 创建数据库连接对象

 2) 使用 GBaseCommand 创建命令对象

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

 } 

 } 

 } 

 }

 }

你可能感兴趣的:(数据库,GBASE南大通用,GBASE)