- Back to Home »
- VB.Net »
- WCF Function and Database Record Updation
WCF Function in ".aspx" File:
<body>
<form id="form1" runat="server">
************************************************************************
<asp:ScriptManager ScriptMode="Release" LoadScriptsBeforeUI="false" ID="sct" runat="server">
<Services>
<asp:ServiceReference Path="~/wcfServices/Service1.svc" />
</Services>
</asp:ScriptManager>
****************************************************************
<script language="javascript" type="text/javascript">
function changestatus(val)
{
Service1.change_status(val, OnSuccess, OnFailed, "");
return false;
}
function OnSuccess(res) {
if (res != "") {
}
else {
}
}
function OnFailed(res) {
}
</script>
**************************************************************
WCF File:
service1:
<ServiceContract(Namespace:="")> _
<AspNetCompatibilityRequirements(RequirementsMode:=AspNetCompatibilityRequirementsMode.Allowed)> _
Public Class Service1
' Add <WebGet()> attribute to use HTTP GET
<OperationContract()> _
Public Sub DoWork()
' Add your operation implementation here
End Sub
<OperationContract()> _
Public Function change_status(ByVal mid As String) As String
Dim approveqry As String
approveqry = "Update mailbox set status=0 where mailid=" & mid
DBManager.ExecuteNonQuery(approveqry)
Return "read"
End Function
**********************************************************
Call The Function:
server side:
Mail &= " <h3 onclick=" & "'return changestatus(" & dts.Rows(i)("mailid") & ")'" & ">" & dts.Rows(i)("subject") & " <table align='right'><tr><td align='right'> " & dts.Rows(i)("activity") & "</td> </tr></table></h3>"
Mail &= "<div><p>" & dts.Rows(i)("mailcontent") & " </p></div>"