⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sqlservice.asmx

📁 聊天 聊天 聊天 聊天 聊天 聊天
💻 ASMX
字号:
<%@ WebService Language="VB" Class="SQLService"%>
Imports System
Imports System.Web.Services
Imports System.Data
Imports System.Data.OleDb
Imports System.Text


Public Class SQLService: Inherits WebService
 <WebMethod()> Public  Function  TestFunction (vInput as Boolean) As String
	If (vInput = TRUE) Then
 	   TestFunction = "It is the truth..."	
	Else
	   TestFunction = "False!False!False"	
	End if 
   End Function

<WebMethod()> Public Function  add( a as integer, b as integer) as string
   add = cstr(a+b)
end function

<WebMethod()> Public Function  Populate(ConnStr as string, SQL as string) As DataSet
	Dim dv as DataView
	Dim i as integer
	Dim myConnection As OleDbConnection
	Dim myCommand    As OleDbDataAdapter
	Dim ds           As New DataSet
	myConnection = New OleDbConnection(ConnStr)    
	myCommand = New OleDbDataAdapter(SQL, myConnection)
	myCommand.Fill(ds, "vTable")
	'Populate = ds.Tables("vTable").DefaultView
	Populate = ds
End Function

 <WebMethod()>PUBLIC Function RunSql ( ConnStr as string, vsql as string) as String
	Dim Message as string
	try
		message = "Success"
		Dim myConnection As OleDbConnection
		myConnection = New OleDbConnection(ConnStr) 
		Dim mycommand As New OleDbCommand(vsql,myConnection)
		myConnection.Open()
		myCommand.ExecuteNonQuery()
		myConnection.Close()
	 Catch ex As OleDbException
		     Dim errItem   As OleDbError
		     Dim errString As String
		     For Each errItem In ex.Errors
			 errString += ex.Message + " "
		     Next
		     Message = "SQL Error.Details follow:<br/><br/>" & errString
	 catch myException as Exception
		     message = "Exception: " + myException.ToString() 
	end try
	RunSql = message
End Function   
End Class

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -