Results 1 to 3 of 3

Thread: SQLParametersCollection

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Mar 2001
    Location
    Devon, UK
    Posts
    181

    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.

  2. #2

    Thread Starter
    Addicted Member
    Join Date
    Mar 2001
    Location
    Devon, UK
    Posts
    181
    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.

  3. #3
    Frenzied Member Magiaus's Avatar
    Join Date
    Mar 2002
    Location
    swamp land
    Posts
    1,267
    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
  •  



Click Here to Expand Forum to Full Width