GBASE南大通用数据库分享:


GBaseCommand 类

代表一个要对 GBase 数据库执行操作的 SQL 语句。这个类不能被继承。对 于该类所有成员的列表,参考 GBaseCommand 成员。

 继承层次 System.Object 

 |__ System.MarshalByRefObject 

 |__ System.ComponentModel.Component 

 |__ System.Data.Common.DbCommand

 |__ GBase.Data.GBaseClient.GBaseCommand

 语法 

 [ Visual Basic ] 

 Public NotInheritable Class GBaseCommand _ 

 Inherits DbCommand _

 Implements ICloneable 

 [ C# ] 

 public sealed class GBaseCommand : DbCommand, Icloneable

 必要条件 命名空间:GBase.Data.GBaseClient

 线程安全性 这个类型的公共静态成员(在 Visual Basic 中为 Shared)对于多线程操 作是保证线程安全的,对于实例不保证线程安全性。

 注释

1) GBase ADO.NET 使用“?”符号来定位 SQL 中的参数;

2) GBaseCommand 使用下列方法在 GBase 数据库中执行命令;

GBASE南大通用数据库分享-GBase ADO.NET 的客户端,GBaseCommand 类_数据库

3) 用户可以重置 CommandText 属性,但必须在执行新的或者前面使用过 的命令之前关闭 GBaseDataReader。

 示例

下面的例子创建了一个GBaseCommand 对象和一个 GBaseConnection对象。 GBaseConnection 对象打开并关联 GBaseCommand 的 Connection 属性。然后调用 ExecuteNonQuery,并关闭连接。 

 [Visual Basic]

 Public Sub InsertRow(gsConnectionString As String) 

 ' If the connection string is null, use a default.

 If gsConnectionString = "" Then

gsConnectionString = "Database=Test;DataSource=localhost; "_

 &"User Id=username; 

 Password=pass;Pooling=false " 

 End If 

 Dim gsConnection As New GBaseConnection(gsConnectionString)

customerId, "_ & "amount) Values(1001, 23,30.66)"

Dim gsCommand As New GBaseCommand(gsInsertQuery)

 gsCommand.Connection = gsConnection gsConnection.Open() 

 gsCommand.ExecuteNonQuery()

 gsCommand.Connection.Close()

 End Sub 

 [C#] 

public void InsertRow(string gsConnectionString)

 {

 // If the connection string is null, use a default.

 if(gsConnectionString == "") 

 { 

 gsConnectionString = "Database=Test;Data Source=localhost; 

 UserId=username; 

 Password=pass"; 

 } 

 GBaseConnection gsConnection = new

 GBaseConnection(gsConnectionString); 

 string gsInsertQuery = "INSERT INTO Orders (id, customerId, amount) Values(1001, 23, 30.66)"; 

 GBaseCommand gsCommand = new GBaseCommand(gsInsertQuery); 

 gsCommand.Connection = 

gsConnection; 

 gsConnection.Open(); 

 gsCommand.ExecuteNonQuery();

 gsCommand.Connection.Close();

 } 



#GBASE南大通用数据库分享