G
Guest
Asp.Net
Visual Studio 2003
SQL Server.
Hi,
I have database in Sqlserver and ListBox (Multiple Selection Mode) in my
Visual Studio Webform. I wish obtain various records from My_Store_Procedure
and fill dataset.
I used the following code and no work:
.....
Sub ChangeWhereClause(Sender As System.Object, e As System.EventArgs)
Dim strWhereClause As String = ""
For Each li in listbox1.Items
If li.Selected Then
strWhereClause &= "EmployeeID=" & li.Value & " Or " '<----------
what is wrong?
End If
Next
If strWhereClause.Length > 0 Then
strWhereClause = Left(strWhereClause, strWhereClause.Length() - 4)
strWhereClause = "WHERE " & strWhereClause
Dim strSql = "Select * " _
& "From My_Store_Procedure " & strWhereClause & " Order By
LastName"
....
In the listbox simple selection mode i used the following code:
Me.SqlSelectCommand1.Parameters("@EmployeeID").Value =
listbox1.SelectedItem.Value
and work fine.
In the listbox multiple selection i Tryed put:
strWhereClause &= "EmployeeID=" &
Me.SqlSelectCommand1.Parameters("@EmployeeID").value = li.Value
& " Or " ' <-------------------- what is wrong?
instead of:
strWhereClause &= "EmployeeID=" & li.Value & " Or "
....and no work.
In listbox multiselection mode:
How to dealing with parameters?
How to pass the parameter? "@EmployeeID".
For example: @EmployeeID instead EmployeeID
Thank you in advance,
Adis.
Visual Studio 2003
SQL Server.
Hi,
I have database in Sqlserver and ListBox (Multiple Selection Mode) in my
Visual Studio Webform. I wish obtain various records from My_Store_Procedure
and fill dataset.
I used the following code and no work:
.....
Sub ChangeWhereClause(Sender As System.Object, e As System.EventArgs)
Dim strWhereClause As String = ""
For Each li in listbox1.Items
If li.Selected Then
strWhereClause &= "EmployeeID=" & li.Value & " Or " '<----------
what is wrong?
End If
Next
If strWhereClause.Length > 0 Then
strWhereClause = Left(strWhereClause, strWhereClause.Length() - 4)
strWhereClause = "WHERE " & strWhereClause
Dim strSql = "Select * " _
& "From My_Store_Procedure " & strWhereClause & " Order By
LastName"
....
In the listbox simple selection mode i used the following code:
Me.SqlSelectCommand1.Parameters("@EmployeeID").Value =
listbox1.SelectedItem.Value
and work fine.
In the listbox multiple selection i Tryed put:
strWhereClause &= "EmployeeID=" &
Me.SqlSelectCommand1.Parameters("@EmployeeID").value = li.Value
& " Or " ' <-------------------- what is wrong?
instead of:
strWhereClause &= "EmployeeID=" & li.Value & " Or "
....and no work.
In listbox multiselection mode:
How to dealing with parameters?
How to pass the parameter? "@EmployeeID".
For example: @EmployeeID instead EmployeeID
Thank you in advance,
Adis.