GBASE南大通用GBaseConnection 类处理

GBASE南大通用

代表一个打开的 GBase 服务器数据库连接。这个类不能被继承。对于该类所有成员的列表,参考 GBaseConnection 成员。

 继承层次

System.Object

|__ System.MarshalByRefObject

|__ System.ComponentModel.Component

|__ System.ComponentModel.Component

|__ GBase.Data.GBaseClient.GBaseConnection

 语法

[ Visual Basic ]    

Public NotInheritable Class GBaseConnection _

Inherits DbConnection _

Implements ICloneable

[ C# ]

public sealed class GBaseConnection : DbConnection, Icloneable

 必要条件

命名空间:GBase.Data.GBaseClient

 线程安全性

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

 注释

一个 GBaseConnection 对象代表一个 GBase 数据源的连接。当用户创建一个 GBaseConnection 实例的时候,所有属性被设置为初始值。对于这些值的列表,参考 GBaseConnection 构造函数。

如果 GBaseConnection 完成功能后,用户调用 Close 关闭连接。

 示例

下面的例子创建了一个 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;

"_

&"UserId=username;Password=pass;pooling=false"

End If

Dim gsConnection As New GBaseConnection(gsConnectionString)

Dim gsInsertQuery As String = "INSERT INTO Orders (id, 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;

User Id=username;Password=pass;pooling=false";

}

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南大通用,GBASE)