setup a new jquery RRS feed

  • Question

  • User-1997257017 posted

    I would like to change the sql to jquery

    I need to change the following code so that it can be executed in a javascript function in a web form 2010 application.

    When the code is actually running, there will be 2 parameters which are for personID and school year. The code needs to

    return the interger value from the count. Basically I am looking for duplicate records where the user working with the vendor software

    updates the data incorrectly. My goal is to display an error message to the user when the count > 1.

    The code is the following:

         #Region "Public Shared Function GetDupScoolYear" 
        <WebMethod()> _ 
        Public Shared Function GetDupScoolYear() As DataTable 
            Dim _dt As DataTable = New DataTable() 
            Dim Query As String = "SELECT [personID],value, count(*) as Count FROM 
           [t].[dbo].[CustomStudent] where attributeID = 2775 and [personID] = 9766 and 
            schoolyear= 2017       
           by [personID],value" 
            Using con As SqlConnection = DB.OpenConnection() 
                Using da As SqlDataAdapter = New SqlDataAdapter(Query, con) 
                    Catch ex As Exception 
                    End Try 
                End Using 
                End Using 
               Return _dt 
             End Function 
           #End Region 

    Thus would you show me the code on how to change the above to a jquery?

    Wednesday, August 24, 2016 3:06 AM


All replies

  • User702547207 posted

    You can call the web method from jquery and pass the result as json and you can validate the data.

    Wednesday, August 24, 2016 5:34 AM
  • User-1997257017 posted

    Can you tell me how to do the following:

    1. Call the web method from jquery?

    2. Can you show me how to pass the result as json and validate the data? Why would I pass the result as json and why would I need to validate the data?

    Wednesday, August 24, 2016 2:58 PM
  • User1724605321 posted

    Hi wendy,

    1. Call the web method from jquery?

    You could use Jquery Ajax to call server side function , please refer to below article for details :



    Can you show me how to pass the result as json and validate the data? Why would I pass the result as json and why would I need to validate the data?

    In your server side function , you could check whether the count>0  , if count>0 you could return "false" string to client side(or other type values ,for example , 0,1) . Then in client side , show error message when response is "false" .

    Best Regards,

    Nan Yu

    Thursday, August 25, 2016 3:20 AM
  • User-1997257017 posted

    In your reference to http://www.aspsnippets.com/Articles/Calling-server-side-methods-using-JavaScript-and-JQuery-in-ASP.Net.aspx,

    would you have a link on how to explain the options in the ajax call, This would be from the following code:


            type: "POST",

            url: "CS.aspx/GetCurrentTime",

            data: '{name: "' + $("#<%=txtUserName.ClientID%>")[0].value + '" }',

            contentType: "application/json; charset=utf-8",

            dataType: "json",

            success: OnSuccess,

            failure: function(response) {





    Thursday, August 25, 2016 3:53 AM
  • User1724605321 posted


    Please refer to this link :


    Best Regards,

    Nan Yu

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, August 25, 2016 5:05 AM
  • User-1997257017 posted

    Just have just about answered my questions so far.

    I have the following additional questions:

    1. I am assuming the application will return to the JavaScript Code that called it, correct? If not, would you tell me why it would not return to the point it was called from?

    2. To obtain the values from the call to the database, I am assuming the data would be in the onSuccess statement? Would you tell me where I look to see the values returned from the call to the database and point me to a way to access the results?

    Thursday, August 25, 2016 2:48 PM