שלום,
אני רוצה לבצע שימוש ב sql עם פרמטרים, עכשיו הגדרתי פרמטר, כאשר הייתי צריך לעשות WHERE עם הפרמטר עשיתי את זה באופן הבא וזה פעל בצורה טובה.
If DropDownList2.SelectedItem.ToString <> " הכל" Then
Dim par1 As New SqlParameter("CityT", DropDownList2.SelectedItem.ToString)
objDA.SelectCommand.Parameters.Add(par1)
Str += " and (Tcity= @CityT or Fcity= @CityT) "
End If
עכשיו כאשר אני רוצה לבצע LIKE לפרמטר בצורה הבאה זה מביא לי הודעת שגיאה,
If txtTo.Text <> "" Then
Dim par2 As New SqlParameter("CityF", txtTo.Text)
objDA.SelectCommand.Parameters.Add(par2)
Str += " and (Fcity LIKE '%" & @CityF & "%' )"
End If
מישהו יכול להסביר לי מדוע.