Introduction
This article will be useful for beginners for learning about Web Services. Create a local database (MS-Access) and create a new Web Service application to connect
to this database. Create the local database connection as a class file.
// Beginning of Class File
Imports System.Data.OleDb
Public Class DBConnection
Dim str As String
Dim con As OleDbConnection
Public Function OpenConnection() As String
con = New OleDbConnection
con.ConnectionString = DBopen()
con.Open()
End Function
Public Function DBopen() As String
str = "Provider=Microsoft.Jet.OLEDB.4.0;User ID=Admin;" & _
"Data Source=D:\AndavarSalary.mdb;"
Return str
End Function
End Class
// End of the Class File
Open the Web Services form "WService.asmx" to create a web method. Import the required namespaces and add the required classes.
Imports System.Web.Services
Imports System.Data.OleDb
<WebMethod()> _
Public Function Addition(ByVal a As String) As DataSet
Dim DBconn As OleDbConnection Dim cls As DBConnection cls = New DBConnection
DBconn = New OleDbConnection
DBconn.ConnectionString = cls.DBopen
Dim ds As New DataSet
Dim sql As String
If a <> 0 Then
sql = "select * from tbl_test where s_no='" & a & "'"
ElseIf a = 0 Then
sql = "select * from tbl_test"
End If
Dim apt As OleDbDataAdapter
apt = New OleDbDataAdapter(sql, DBconn)
apt.FillSchema(ds, SchemaType.Source, "Load")
apt.Fill(ds, "Load")
Return ds
End Function
The above code is only on the Web Service's web pages. Now the Web Service is successfully created.
After executing your Web Sservice application, you can get the URL of the page: http://localhost/Sample/WService.asmx.

Next create your WebForm on another machine for accessing the local database values. The following steps can be followed..
Go to your web application and add the required web references. Add the URL, paste this URL like http://system IP Address/Sample/WService.asmx.

Open your webform1.aspx, design the form: just put in a TextBox and a Button.
Go to the Button's Click event and write this code:
Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click
Dim ds As New DataSet
Dim wsdataset As WebReference.WService
wsdataset = New WebReference.WService
If TextBox1.Text <> "" Then
ds = wsdataset.Addition(TextBox1.Text)
Else
ds = wsdataset.Addition(0)
End If
DataGrid1.DataSource = ds
DataGrid1.DataBind()
End Sub
Execute your web application. Now you will be able to get the values in the local database tables. If you need any more information on this, please let me know.