Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to store to command paramter collection

Status
Not open for further replies.

kebele

MIS
Joined
Jul 31, 2006
Messages
107
Location
US
I have multiple value return from the below code and I would like to store this value into paramter collection and i am not sure how i do that.any help would be appreciated.
strVendor could hold vendor name A, B, C .....

Dim strSVendor As String = ""
For Each liThisOne In lstState.Items
If liThisOne.Selected Then
strVendor = strVendor & "'" & liThisOne.Value & "'" & ","
End If
Next
myCommand3.Parameters.AddWithValue(":Vendorname",strVendor)
 
Hi,
What happens when you use the code you posted?
Looks good, except that you will have a trailing comma...

I would modify it this way:
Code:
Dim strSVendor As String = ""
        For Each liThisOne In lstState.Items
           If liThisOne.Selected Then
               strVendor = strVendor & "'" & liThisOne.Value & "'" & ","
           End If
        Next
[COLOR=red]
strVendor = left(strVendor,len(strVendor) -1)
[/color]
  myCommand3.Parameters.AddWithValue(":Vendorname",strVendor)

Also, you seem to have a typo in the StrVendor name, is it strVendor or strSVendor?



[profile]

To Paraphrase:"The Help you get is proportional to the Help you give.."
 
Turkbear thanks for the reply I did the correction as you suggested and i am still getting error msg. here is my code can you look at it again

Dim strVendor As String = ""
For Each liThisOne In lstState.Items
If liThisOne.Selected Then
strVendor = strVendor & "'" & liThisOne.Value & "'" & ","
End If
Next

If strVendor.Length > 0 Then
gvSearch.Visible = True
strVendor = Left(strVendor, strVendor.Length - 1)
strVendor = "(" & strVendor & ")"

Dim Sql As String = " SELECT DISTINCT V.VENDOR,R.ADDRNUM,V.VNAMEL,R.AADDR1,R.ACITY,R.VASST1 "
Sql = Sql & "FROM VENDOR V,VENDADDR R, PLANHOLD P "
Sql = Sql & "WHERE V.VENDOR = R.VENDOR AND P.VENDOR = R.VENDOR "
Sql = Sql & "AND P.DATEPUR In ( select Max(P.DATEPUR) from PLANHOLD P where P.vendor = R.VENDOR) "
Sql = Sql & "AND R.ASTATE IN :Vendorname"
Sql = Sql & "AND V.VOBSOLET = 'N' "
Sql = Sql & "ORDER BY V.VENDOR "

Dim myCommand3 As OracleCommand = New OracleCommand(Sql, New OracleConnection(GetConnectionString()))
myCommand3.Parameters.AddWithValue(":Vendorname", strVendor)
Dim myAdapter3 As New OracleDataAdapter(myCommand3)

Dim myDataSet As New DataSet
myAdapter3.Fill(myDataSet, "VendorSearch")

gvSearch.DataSource = myDataSet
gvSearch.DataBind()
lblTotal.Text = gvSearch.Rows.Count

Else
gvSearch.Visible = False


 
Where and what is exact error?

Sharing the best from my side...

--Prashant--
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top