locked
data update using control RRS feed

  • Question

  • User-1547866623 posted

    Hi,

    I am new to programming, I am working on creating new web service that update database. My requirement is using a web services with vb.net.

    PLEASE HELP!

    Rani

    Friday, March 26, 2021 2:05 PM

All replies

  • User-939850651 posted

    Hi rani_shah19,

    According to your description, I created a simpe demo, you could refer to it:

    <head runat="server">
        <title></title>
        <script src="Scripts/jquery-3.4.1.min.js"></script>
        <script>
            $(function () {
                $('#UpdateBtn').on('click', function () {
                    $.ajax({
                        url: 'WebService1.asmx/UpdateDataBase',
                        type: 'post',
                        contentType: 'application/json,charset=UTF-8',
                        data: {},
                        dataType: 'xml',
                        success: function (responseData) {
                            var result = responseData.getElementsByTagName("string")[0].childNodes[0].nodeValue;
                            if (result == "ok") {
                                console.log('update successfully!')
                            } else {
                                console.log('update failed...')
                            }
                        },
                        error: function (e) {
                            alert("something wrong.");
                        }
                    })
                })
            });
        </script>
    </head>
    <body>
        <form id="form1" runat="server">
            <div>
                <input type="button" id="UpdateBtn" value="Update" />
            </div>
        </form>
    </body>
    <System.Web.Script.Services.ScriptService()>
    <System.Web.Services.WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)>
    <ToolboxItem(False)>
    Public Class WebService1
        Inherits System.Web.Services.WebService
    
        <WebMethod()>
        Public Function UpdateDataBase() As String
            Try
                'Code about update database
                'Update successfully then return result
                Return "ok"
            Catch ex As Exception
                'get exception then return result
                Return "failed"
            End Try
        End Function
    
    End Class

    But the part of updating the database needs to be coded appropriately according to your own situation.

    For more details ,you could refer to the use of  .asmx web service.

    If I misunderstood anything, please describe more details about your problem.

    Best regards,

    Xudong Peng

    Monday, March 29, 2021 7:00 AM