none
i want to validate value of parameter in sqlquery in my wcf service? RRS feed

  • Question

  • Public Function GetMachines1(ByVal value As String) As List(Of Common.DataContract.Machine) Implements IService1.GetMachines1 'Using oDL As New Datalogic.Class1 Return oDL.GetMachineList 'End Using End Function Public Function GetMachineList(ByVal value as String) As List(Of Common.DataContract.Machine) Dim oConn As New xxxxx Dim machines As New List(Of Common.DataContract.Machine)() Dim strSql As String = "SELECT k_koneno AS ma_machineid,k_paikka AS ma_placenumber,k_malli AS ma_model,k_tyyppi AS ma_type,k_versio AS ma_version FROM kone where k_paikka = '" & value & '"

    i am trying to place integer in the form of string.

    but query is getting the value and settting the column equal to myvalue. It is not checking it just replacing the original value with my value.

    I want to check the value?

    if both values are the same then return.

    and value is integer in the form of string.

    Thanks

    Tuesday, October 21, 2014 10:15 AM

Answers

  • Hi Miskeen Ali Jatoi,

    >>but query is getting the value and settting the column equal to myvalue. It is not checking it just replacing the original value with my value.

    I am not sure if I have understood the above message, if so please try to check the following code to see if it helps:

    string strSql="SELECT k_koneno AS ma_machineid,k_paikka AS ma_placenumber,k_malli AS ma_model,k_tyyppi AS ma_type,k_versio AS ma_version FROM kone where k_paikka =@value " SqlConnection connection = new SqlConnection(/* connection info */); SqlCommand command = new SqlCommand(sql, connection); if(myvalue==value)
    { return....
    } else { command.Parameters.AddWithValue("@value", Convert.ToString(value);); }

    Best Regards,
    Amy Peng


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.





    Wednesday, October 22, 2014 5:55 AM
    Moderator