//一个后台数据库接受前台传值并做插入与删除具体实现
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