trim string at the end of the string

前端 未结 6 812
时光说笑
时光说笑 2021-01-16 07:01

Hello I want to remove the last word from my sentence in C#. Here is my query:

\"SELECT * FROM People WHERE City = @City AND County = @County AND\"
         


        
6条回答
  •  日久生厌
    2021-01-16 07:35

    Multiple methods for fixing the string given already.

    This looks like dynamically generated SQL, so, the more sensible solution in my mind is to never have the final AND there. This can be done by counting the number of parameters you've added to the where clause, and prepending the and for every parameter after the first.

提交回复
热议问题