We help IT Professionals succeed at work.
Get Started

Trying to learn C# and Web Service

Bob Bender
Bob Bender asked
Last Modified: 2012-05-06
Okay...I'm trying to learn something new and having problems.
I want to write a webservice and use an aspx file to read it.  All files will be located on my 'work' web server,  My database is in MS Access 2005.  I have written my asmx file and compiled it okay with wsdl to get my cs file, and used csc to convert that to DLL.  So, I am able to call my asmx file and get the method listing.


I am trying to read the Access db using an OLEdb, and NOT Sql C# syntax.  Is this correct?

I think that using a datagrid might be a problem.

Any ideas?  Help...an explanation.....PPLLEEAASSEE (whiny voice)


my ASMX file
<%@ WebService Class="BeerServiceDB" Language="C#" %>
using System;
using System.Web.Services;
using System.Data;
using System.Data.OleDb;
[WebService( Namespace="http://web2.bender.com/rkoch1/webservices" )]
public class BeerServiceDB : WebService
    [WebMethod(Description="This method returns the 'Beer' catalog.")]
        public DataSet processQuoteRequest() {
            string strSelect = "Select ProductName, ProductDescription, UnitPrice, filepath From Beers;";
            OleDbConnection myConnection = new OleDbConnection "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=../Database/KochBeer.mdb");
           OleDbCommand myCommand = new OleDbCommand(strSelect, myConnection);
           OleDbDataAdapter myDataAdapter = new OleDbDataAdapter(myCommand);
           DataSet myDataSet = new DataSet();
           myDataAdapter.Fill(myDataSet, "Beers");
           return myDataSet;
Attempted ASPX file to read and send back a DataSet with the data.
<%@ Page Language="C#" %>
<script language="C#" runat=server>
void Page_Load(Object sender , EventArgs e) {
     BeerServiceDB objBeers = new BeerServiceDB();
     dgrdBeers.DataSource = objBeers.processQuoteRequest();
<h2>Available Beers:</h2>
<asp:DataGrid  ID="dgrdBeers"  Runat="Server"/>

Open in new window

Watch Question
Python Developer
This problem has been solved!
Unlock 1 Answer and 3 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE