|
-
Aug 29th, 2002, 05:22 AM
#1
Thread Starter
Addicted Member
SQLParametersCollection
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.
Wind and waves resolves all problems.
-
Aug 30th, 2002, 03:15 AM
#2
Thread Starter
Addicted Member
Sorted - for anybody interested basically the sqlparameterscollection is dependant upon a command object and is not something you can create on its own. As I am passing parameters to my class the command object hasn't been created. Anyway got around it by using an object array with my sqlparameters (which u can create without a command object!) in it.
Wind and waves resolves all problems.
-
Aug 30th, 2002, 11:38 AM
#3
Frenzied Member
cmd.Execute ,Array(param1,parram2,parram3) is the oldway i belive it is simular now except you have more execute options and i think ms is pushing the parameter collection
Magiaus
If I helped give me some points.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|