Network programming in C#, Network Programming in VB.NET, Network Programming in .NET
Available now!
Buy at Amazon US or
Buy at Amazon UK



Articles

1.Windows API reference
2.HTML to WML Converter
3.Webcam streaming in VB.NET
4.Remoting with firewalls
5.RSA from first principles
6.Key & MouseLogger in .NET
7.Networking Resource Kit for .NET
8.Automatic Reboot with .NET
9.XAML Schema
10.Migrating VB6 Winsock to VB.NET
11.Migrating C++ sockets to C#
12.RFC Reference guide
13.Lingua - Localization webservice
14.COM Reference guide
15.WMI Reference guide
16.SQL stored procedures
17.TCP & UDP port reference
18..NET Framework reference
19.Ethernet Type codes
20.IP to country webservice
21.MAC address assignments
22.DLL entry point reference
23.WHOIS server list
24. Turing Numbers
25. Boost SQL performance
26. Progress Bar in ASP.NET
27. OleDb WebService
27. Internet Explorer

Contact us

OleDb web service



Download source code (93kb)
The purpose of this article is to demonstrate how to control a remote microsoft access (or any other oledb supporting databasae) over the internet via a web service. This web service provides a generic architecture to access all forms of OleDb supporting databases over the internet via a webservice. This would include basic rights management, such as a username/password and ReadOnly access option. The benifit of accessing a database over the internet, is (a) for syndicating information to partners, (b) to provide rapid remote updates - without having to download & upload the entire database to make a non-standard update. This web service also supports:
  • Active Directory Service
  • Advantage
  • AS/400 (from IBM)
  • AS/400 and VSAM (from Microsoft)
  • Commerce Server
  • DB2
  • DTS Packages
  • Exchange
  • Excel
  • Internet Publishing
  • Index Server
  • Microsoft Jet
  • Microsoft Project
  • MySQL
  • ODBC Databases
  • OLAP Services
  • Oracle (from Microsoft)
  • Oracle (from Oracle)
  • Pervasive
  • Simple Provider
  • SQLBase
  • SQL Server
  • SQL Server via SQLXMLOLEDB
  • Sybase Adaptive Server Anywhere
  • Sybase Adaptive Server Enterprise
  • Text Files
  • UniData and UniVerse
  • Visual FoxPro
For connection strings for the above databases, a useful website is Able consulting.

Using the OleDb web service

To install the web service, as included in the DLL, upload it to the /bin folder on your server, and copy config.xml into the bin folder also. Copy service.asmx to your root folder (you can rename this file to something more meaningful).
1. Open a new project in visual studio.net, and make a new web reference to www.yourserver.com/service.asmx, and call it dbwebservice.
2. Drag a button and a datagrid onto the form, double click on the button.
3. Populate your databaseAccessParams class, thus:

dbwebservice.databaseAccessParameters dbParams = new dbwebservice.databaseAccessParameters();
dbParams.connectionString = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=C:\\home\\webtropy\\dict.mdb";
dbParams.sql= "select top 50 * from wb1913_a where field5 like '%ing'";
dbParams.username="john";
dbParams.password="pass";

(Modify the connection string according to your own database)
4. Pass this object to your webservice, and bind the result to the database thus:
dbwebservice4.OleDbWebService service = new dbwebservice4.OleDbWebService();
DataSet ds = service.ExecuteDataSet(dbParams);
DataTable dt = ds.Tables["sql"];
DataView dv = new DataView(dt);
this.dataGrid1.DataSource = dv;    

The web service can be used from a asp.net page aswell. Please leave a note on the page if you've got an on-line example of this service running under aspx.

Project overview

The project is developed in Visual Web Developer 2005, - simply because it had a in-built web server, which I don't have on my development machine. I will then port the project from .NET 2.0 beta to .NET 1.1 so that the DLL is portable to production servers. The four main operations that the application needed to perform was - (a) read a dataset, (b) execute an update or insert, (c) retrieve a single value, and (d) retrieve database schema.

One of the core requirements of the application was to provide a rights management system. Because, when you provide a webservice like this, you may only want a selected few individuals read your database, and even then, you may nor want them to change your data. To provide this, I created a congiguration xml file called config.xml (NOT web.config) in the same /bin folder as the web service DLL. - Containing this:


<security>
 <username>john</username>
 <password>pass</password>
 <readOnly>true</readOnly>
</security>
Meaning that a user "John" with password "Pass" could read from my database, but not write to it.

Unfortunately, the option to retrieve schema was dropped, after encountering some difficulties trying to reflect the schema data as it was returnerd from the webservice. More information on this is written on my blog at msn spaces. Similarly, I was hoping to have the provided username and passsword as properties, and managed internally using session state management (where you declare EnableSession = true for each method). However, this didn't work from my windows forms client, so I resorted to declaring a class called databaseAccessParameters, and passing this to all the functions.




Google

Free SMS UK Free SMS Ireland SMS Gratis Norway SMS Gratis Sverige Ilmainen SMS Suomi SMS Gratis Danmark SMS Tasuta Eestisse SMS Nemokamai Lietuva SMS Bezmaksas Latviju Darmowe smsy Polska SMS Zdarma Ceské SMS Zdarma Slovensko SMS Gratis Deutschland SMS Gratis Schweiz SMS Gratis Österreich SMS Gratuit Belgique SMS Gratis Nederland SMS Gratuit France SMS Gratis Espańa SMS Gratis Portugal Free SMS South Africa Free SMS USA SMS Percuma Malaysia Free SMS Hong Kong