cim3
Aug 29th, 2002, 05:22 AM
Has anyone used the sqlparameters collection yet??
Having a few problems adding parameters to it. I am passing the collection to a class to get a dataset.
This is the code
Dim oData As New cDB()
Dim oDS As DataSet
Dim oParam As New SqlParameter()
Dim oParamCol As SqlParameterCollection
With oParam
.ParameterName = "@criteria"
.SqlDbType = SqlDbType.VarChar
.Size = 255
.Value = txtSearchBasic.Text.ToString
End With
oParamCol.Add(oParam)
With oParam
.ParameterName = "@type"
.SqlDbType = SqlDbType.VarChar
.Size = 20
If rbSearchProv.Checked = True Then .Value = "Provider"
If rbSearchProp.Checked = True Then .Value = "Property"
If rbSearchSer.Checked = True Then .Value = "Service"
If rbSearchClient.Checked = True Then .Value = "Client"
End With
oParamCol.Add(oParam)
oDS = oData.GetDataSet("BasicSearch", oParamCol)
However it says an instance of oParamCol = nothing. But add New Keyword to SqlParameterCollection and says its not accessible in this context because it is private. Surely collections can be added too and passed about. The only examples on the net have you adding parameters directly to command object.
Having a few problems adding parameters to it. I am passing the collection to a class to get a dataset.
This is the code
Dim oData As New cDB()
Dim oDS As DataSet
Dim oParam As New SqlParameter()
Dim oParamCol As SqlParameterCollection
With oParam
.ParameterName = "@criteria"
.SqlDbType = SqlDbType.VarChar
.Size = 255
.Value = txtSearchBasic.Text.ToString
End With
oParamCol.Add(oParam)
With oParam
.ParameterName = "@type"
.SqlDbType = SqlDbType.VarChar
.Size = 20
If rbSearchProv.Checked = True Then .Value = "Provider"
If rbSearchProp.Checked = True Then .Value = "Property"
If rbSearchSer.Checked = True Then .Value = "Service"
If rbSearchClient.Checked = True Then .Value = "Client"
End With
oParamCol.Add(oParam)
oDS = oData.GetDataSet("BasicSearch", oParamCol)
However it says an instance of oParamCol = nothing. But add New Keyword to SqlParameterCollection and says its not accessible in this context because it is private. Surely collections can be added too and passed about. The only examples on the net have you adding parameters directly to command object.