?? sqlservice.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 + -