using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;
using System.Data;
using System.Data.OleDb;

namespace WcfServiceApplication
{
    // NOTE: If you change the class name "Service1" here, you must also update the reference to "Service1" in Web.config and in the associated .svc file.
    public class Service1 : IService1
    {
        public DataTable GetSimpleData()
        {
            OleDbDataAdapter custDA = new OleDbDataAdapter();
            OleDbConnection aConnection = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source= |DataDirectory|Nwind.mdb");

            DataTable dt = new DataTable();
            try
            {
                aConnection.Open();
                DataSet ds = new DataSet();
                OleDbDataAdapter adapter = new OleDbDataAdapter("Select * from Customers", aConnection);
                adapter.Fill(ds);
                aConnection.Close();
                dt = ds.Tables[0];
            }
            catch (OleDbException e)
            {

            }

            return dt;
        }

        public DataTable GetAdditionalData(string value)
        {
            OleDbDataAdapter custDA = new OleDbDataAdapter();
            OleDbConnection aConnection = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source= |DataDirectory|Nwind.mdb");

            DataTable dt = new DataTable();
            try
            {
                aConnection.Open();
                DataSet ds = new DataSet();
                OleDbDataAdapter adapter = new OleDbDataAdapter();

                OleDbCommand command;
                command = new OleDbCommand("SELECT * FROM Customers " +
                    "WHERE CustomerID = ?", aConnection);

                command.Parameters.Add("@CustomerID", OleDbType.VarChar, 15).Value = value;
                adapter.SelectCommand = command;
                adapter.Fill(ds);

                aConnection.Close();
                dt = ds.Tables[0];
            }
            catch (OleDbException e)
            {

            }

            return dt;
        }
    }
}
