ajax传值到ASP.NET的aspx文件后台代码实现(VB)

ajax前台js代码实现

//一个后台数据库接受前台传值并做插入与删除具体实现
Imports System.Web.Script.Services
Imports System.EnterpriseServices
Imports System.Web.Services
Imports System.Data
Imports System.Data.OleDb
Public Class data
    Inherits System.Web.UI.Page
    <System.Web.Services.WebMethod()>
    Public Shared Function Insert(ByVal thisID As String, ByVal otherID As String) As String
        Dim conn As New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source= " & "|DataDirectory|web.accdb")
        Dim mystr As String
        mystr = "Insert Into follow([thisID],[otherID]) Values(" & thisID & "," & otherID & ")"
        Dim cmd As New OleDbCommand(mystr, conn)
        conn.Open()
        cmd.ExecuteNonQuery()
        conn.Close()
        Return "insert sucess!"
    End Function
    <System.Web.Services.WebMethod()>
    Public Shared Function Delete(ByVal thisID As String, ByVal otherID As String) As String
        Dim conn As New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source= " & "|DataDirectory|web.accdb")
        Dim mystr As String
        mystr = "delete from follow where thisID=" & thisID & " and otherID = " & otherID
        Dim cmd As New OleDbCommand(mystr, conn)
        conn.Open()
        cmd.ExecuteNonQuery()
        conn.Close()
        Return "delete sucess!"
    End Function
End Class

基本框架

Imports System.Web.Script.Services
Imports System.EnterpriseServices
Imports System.Web.Services
Public Class data
    Inherits System.Web.UI.Page
    <System.Web.Services.WebMethod()>//这是必要的
    Public Shared Function 函数名称(传递值) As String
       //你的函数代码
       return 返回值(本例此处为string)
    End Function
End Class

转载于:https://www.cnblogs.com/xLester/p/7570345.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值