GBASE南大通用Connection 属性

2024-01-08 21:33:48

获取或设置GBASE南大通用 Command 实例使用的 GBaseConnection 对象。

? 语法

[Visual Basic]

Public Property Connection As GBaseConnection

Get

Set

[C#]

public GBaseConnection Connection { get; set; }

? 注释

GBASE南大通用当事务在进行中且 Transaction 属性为空时,如果用户设置了 Connection,

那么会产生 InvalidOperationException。如果 Transaction 属性不是 null 且

事务已经提交或者回滚了,Transaction 将被自动设置为 null。

? 示例

下面的例子创建了 GBaseCommand 且设置了它的一些属性。

[Visual Basic]

Public Sub CreateGBaseCommand()

Dim gsSelectQuery As String="SELECT * FROM gstable ORDER BY id"

Dim gsConnectString As String = "Persist SecurityInfo=False; "_

& "database=test; "_

& "servser=gsServer"

Dim gsCommand As New GBaseCommand(gsSelectQuery)

gsCommand.Connection = New GBaseConnection(gsConnectString)

gsCommand.CommandType = CommandType.Text

End Sub

[C#]

public void CreateGBaseCommand()

{

string gsSelectQuery = "SELECT * FROM gstable ORDER BY id";

string gsConnectString = "Persist

SecurityInfo=False;database=test;

server = gsServer";

GBaseCommand gsCommand = new GBaseCommand(gsSelectQuery);

gsCommand.Connection = new GBaseConnection(gsConnectString);

gsCommand.CommandType = CommandType.Text;

}

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