SQL 语句或者存储过程使用的参数集合 GBASE南大通用ParameterCollection,默认是空集合。
? 语法
[Visual Basic]
Public ReadOnly Property Parameters As GBaseParameterCollection
Get
[C#]
public GBaseParameterCollection Parameters { get; }
? 注释
GBase ADO.NET 不支持无名参数。每个加入到集合中的参数必须有一个连接
名字。
? 示例
下面的例子创建一个 GBaseCommand 并显示它的参数。要完成这些,要使用
GBaseConnection,一个 SQL SELECT 查询字符串,和一个 GBaseParameter 对象
数组。
[Visual Basic]
Public Sub CreateGBaseCommand(gsConnection As GBaseConnection,
_
gsSelectQuery As String, gsParamArray() As GBaseParameter)
Dim gsCommand As New GBaseCommand(gsSelectQuery, gsConnection)
gsCommand.CommandText = "SELECT id, name FROM gstable" _
&" WHEREage=?age"
gsCommand.UpdatedRowSource = UpdateRowSource.Both
gsCommand.Parameters.Add(gsParamArray)
Dim j As Integer
For j = 0 To gsCommand.Parameters.Count - 1
gsCommand.Parameters.Add(gsParamArray(j))
Next j
Dim gsMessage As String = ""
Dim i As Integer
For i = 0 To gsCommand.Parameters.Count - 1
gsMessage += gsCommand.Parameters(i).ToString() &
ControlChars.Cr
Next i
Console.WriteLine(gsMessage)
End Sub
[C#]
public void CreateGBaseCommand(GBaseConnection gsConnection,
string gsSelectQuery,GBaseParameter[] gsParamArray)
{
GBaseCommand gsCommand = new GBaseCommand(gsSelectQuery,
gsConnection);
gsCommand.CommandText = "SELECT id, name FROM gstable
WHERE age=?age";
gsCommand.Parameters.Add(gsParamArray);
for (int j=0; j<gsParamArray.Length; j++)
{
gsCommand.Parameters.Add(gsParamArray[j]) ;
}
string gsMessage = "";
for (int i = 0; i < gsCommand.Parameters.Count; i++)
{
gsMessage += gsCommand.Parameters[i].ToString() + "\n";
}
MessageBox.Show(gsMessage);
}?