Find Code:
All Words
Any of the Words
Exact Phrase
Home
:
Code
:
Forums
:
Submit
:
Mailing List
:
About
:
Contact
Code
All
VB.NET
ASP.NET
C#
VB Classic
ASP Classic
Snippets
Popular
Resources
Submit Code
Forums
Articles
Tips
Links
Books
Contest
Link to us
Creating an XML Web Service in ASP.NET
Author:
Peter Riley
E-mail:
Click to e-mail author
Submitted:
7/26/2003
Version:
ASP.NET 1.0
Compatibility:
VB.NET
Category:
XML
Views:
18090
Create a simple XML web service that returns an employee name based on the employee ID provided by the consumer. Searches an Access database of employee records.
Declarations:
'Place the code below in an .asmx file.
Code:
<%@ WebService Language="vb" Class="EmployeeID" %> Imports System.Web.Services Imports System.Data Imports System.Data.OleDb Public Class EmployeeID Inherits System.Web.Services.WebService
_ Public Function BookDetail(ByVal strEmployeeID As String) As String Return GetName(strEmployeeID) End Function Private Function GetName(ByVal strEmployeeID As String) As String Dim objEmpDR As OleDbDataReader Dim objEmpConn As OleDbConnection Dim objEmpCmd As OleDbCommand Dim strConn As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("Emp.mdb") & ";" Dim strSQL As String = "select EmpName from Employees where EmployeeID = '" & strEmployeeID & "'" Dim strEmpName As String objEmpConn = New OleDbConnection(strConn) objEmpCmd = New OleDbCommand(strSQL, objEmpConn) objEmpConn.Open() objEmpDR = objEmpCmd.ExecuteReader(CommandBehavior.CloseConnection) If objEmpDR.Read() Then strEmpName = objEmpDR(0) Else strEmpName = "Employee does not exist." End If objEmpDR.Close() Return strEmpName End Function End Class
Home
|
Forums
|
Submit
|
Books
|
Mailing List
|
Advertising
|
About
|
Contact
© 2023 A1VBCode. All rights reserved.
Legal disclaimer & terms of use
Privacy statement