<%@ webservice Language="c#" Class="DBSrc" %> 
using System;
using System.Web;
using System.Web.Services;
using System.Data;
using System.Data.SqlClient;
using System.Data.OleDb;

public class DBSrc:WebService {
	[WebMethod()]public DataSet GetSQLData(string ServerName,string uid,string Password,string DBName,string TBName){
		string d = "server=" + ServerName + ";uid=" + uid + ";pwd=" + Password + ";database=" + DBName;
		SqlConnection NowConn = new SqlConnection(d);
		DataSet DS = new DataSet();
		string k = "SELECT * From " + TBName;
		SqlDataAdapter NComm = new SqlDataAdapter(k, NowConn);
		NComm.Fill(DS, TBName);
		return DS;
	}
	[WebMethod()]public Boolean SaveSQLData(DataSet DS,string ServerName,string uid,string Password,string DBName,string TBName){
		string d = "server=" + ServerName + ";uid=" + uid + ";pwd=" + Password + ";database=" + DBName ;
		SqlConnection NowConn = new SqlConnection(d);
		string k = "SELECT * From " + TBName;
		SqlDataAdapter NComm = new SqlDataAdapter(k, NowConn);
		try{
			SqlCommandBuilder custCB = new SqlCommandBuilder(NComm);
			NComm.Update(DS,TBName);
			return true;
		}
		catch{
			return false;//保存时发生错误
		}
	}
	[WebMethod()]public DataSet GetACCData(string TBName){
		string x = Server.MapPath("Stock.mdb");
//		x = Left(x,Len(x)-19)
		string f = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + x;
		OleDbConnection ACConn = new OleDbConnection(f);
		DataSet DS = new DataSet();
		string k = "SELECT * From " + TBName;
		OleDbDataAdapter NComm = new OleDbDataAdapter(k, ACConn);
		NComm.Fill(DS, TBName);
		return DS;
	}
	[WebMethod()]public Boolean SaveACCData(DataSet DS,string TBName){
		string x = Server.MapPath("Stock.mdb");
		string f = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + x ;
		OleDbConnection ACConn = new OleDbConnection(f);
		string k = "SELECT * From " + TBName;
		OleDbDataAdapter NComm = new OleDbDataAdapter(k, ACConn);
		try{
			OleDbCommandBuilder custCB = new OleDbCommandBuilder(NComm);
			NComm.Update(DS,TBName);
			return true;
		}
		catch{
			return false;//保存时发生错误
		}
	}
}
