什么是通过网络访问微软访问数据库的最佳方式? [英] Whats the best way to access a microsoft access database over a network?

查看:88
本文介绍了什么是通过网络访问微软访问数据库的最佳方式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望在我们的网络驱动器上有一个小型访问数据库,目的是通过我们的业务共享数据。它将包含几个表,目前它有两个,一个用于产品,一个用于批次。数据库很简单,没有关系或规则,但从空状态更新数据库需要10多分钟。如果我将数据库复制到本地驱动器大约需要一分钟。



我正在填充两个空数据表,然后将它们更新到数据库。



在上一个被删除的问题中,有人建议我处理这个问题的方式可能更好。我使用System.Data.OleDbAdapter作为数据适配器,并使用Jet提供程序,因此不需要在计算机上安装额外的软件。



使用由于我们总部的限制,SQL服务器不适合。



有没有更好的解决方案我想做什么?



如果我不清楚查询,请告诉我



我的代码

I would like to have a small access database on our network drive with the purpose of sharing data over our business. It will contain a few tables, at the moment it has two, one for products and one for batches. The database is simple, no relationships or rules, but it takes over 10 minutes to update the database from an empty state. If I copy of the database to a local drive it takes about a minute.

I am filling two empty data tables and then updating them to the database.

In a previous question which has been deleted, it was suggested that maybe my way of handling this could be better. I am using System.Data.OleDbAdapter for the data adapter, and using the Jet provider as that way no extra software needs to be installed on the computers.

Using a SQL server is not suitable due to restrictions from our head office.

Is there a better solution to what I am trying to do?

Please let me know if I am not clear with my query

My Code

	private ClsProducts Products;
	private ClsBatches Batches;
	private ClsReportHeader ReportHeader;
	private Database database;
		
	public static void Main(string[] args)
	{
		Program Importer = new Program();
		Importer.database = new Database();
		Importer.SetupDataTables();
		Importer.ReadFile();
		Importer.database.Save();
		Console.Write("Press any key to continue . . . ");
		Console.ReadKey(true);
	}
	
	public void SetupDataTables()
	{
		Products = new ClsProducts(database.products_Table);
		Batches = new ClsBatches(database.batches_Table);
	}
	public void ReadFile()
	{
            // Unimportant code
	}
}

public class ClsProducts
{
	private DataTable table; 
	public DataColumn Code;
	public DataColumn Description;
	public DataColumn Group;
	public DataColumn Supplier;
	public DataColumn Brand;
	public DataColumn HOMaintained;
	public DataColumn Active;
	public DataColumn Qty;
	public DataColumn TagCost;
	public DataColumn Retail;
	
	public ClsProducts(DataTable Table)
	{
		table = Table;
		Code = table.Columns["PCode"];
		Description = table.Columns["PDescription"];
		Group = table.Columns["PGroup"];
		Supplier = table.Columns["PSupplier"];
		Brand = table.Columns["PBrand"];
		HOMaintained = table.Columns["PHOMaintained"];
		Active = table.Columns["PActive"];
		Qty = table.Columns["PQty"];
		TagCost = table.Columns["PTagCost"];
		Retail = table.Columns["PRetail"];
	}
	
	public int AddRow()
	{
		table.Rows.Add(table.NewRow());
		return table.Rows.Count - 1;
	}
	
	public int Count
	{
		get
		{
			return table.Rows.Count;
		}
	}
	
	public object this[int RowNumber, DataColumn DC]
	{
		get
		{
			return this.table.Rows[RowNumber][DC];
		}
		set
		{
			this.table.Rows[RowNumber][DC] = value;
		}
	}
}

public class ClsBatches
{
	private DataTable table;
	public DataColumn Code;
	public DataColumn Batch;
	public DataColumn Date;
	public DataColumn Qty;
	public DataColumn Cost;
	public DataColumn Rebate;
	public DataColumn Freight;
	
	public ClsBatches(DataTable Table)
	{
		table = Table;
		Code = table.Columns["BCode"];
		Batch = table.Columns["BBatch"];
		Date = table.Columns["BDate"];
		Qty = table.Columns["BQty"];
		Cost = table.Columns["BCost"];
		Rebate = table.Columns["BRebate"];
		Freight = table.Columns["BFreight"];

	}

	public int AddRow()
	{
		table.Rows.Add(table.NewRow());
		return table.Rows.Count - 1;
	}
	
	public int Count
	{
		get
		{
			return table.Rows.Count;
		}
	}
			
	public object this[int RowNumber, DataColumn DC]
	{
		get
		{
			return this.table.Rows[RowNumber][DC];
		}
		set
		{
			this.table.Rows[RowNumber][DC] = value;
		}
	}
}

public class Database
{
	public OleDbDataAdapter products_Adapter;
	public OleDbDataAdapter batches_Adapter;
	public DataTable products_Table;
	public DataTable batches_Table;
	public OleDbCommandBuilder builder;
	public OleDbConnection connection;
	
	public Database()
	{
		connection = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\grant.mcconville\Database.mdb");
		connection.Open();
		
     	products_Table = new DataTable();
     	batches_Table = new DataTable();
     	
     	products_Adapter = new OleDbDataAdapter("SELECT * FROM TblProducts", connection);
     	products_Adapter.Fill(products_Table);
     	builder = new OleDbCommandBuilder(products_Adapter);
     	products_Adapter.UpdateCommand = builder.GetUpdateCommand();
     	products_Adapter.InsertCommand = builder.GetInsertCommand();
     	products_Adapter.DeleteCommand = builder.GetDeleteCommand();
     	
     	batches_Adapter = new OleDbDataAdapter("SELECT * FROM TblBatches", connection);
     	batches_Adapter.Fill(batches_Table);
     	builder = new OleDbCommandBuilder(batches_Adapter);
     	batches_Adapter.UpdateCommand = builder.GetUpdateCommand();
     	batches_Adapter.InsertCommand = builder.GetInsertCommand();
     	batches_Adapter.DeleteCommand = builder.GetDeleteCommand();
	}
	
	public void Save()
	{
		products_Adapter.Update(products_Table);
		batches_Adapter.Update(batches_Table);
	}
}

推荐答案

Grant Mc问:
Grant Mc asked:



唯一的另一种选择是SQL吗?


Would the only other alternative be SQL?

如果你想要SQL,肯定是。您可以考虑使用一组优秀的基于SQL的数据库服务器,专有或开源:

http:/ /en.wikipedia.org/wiki/List_of_relational_database_management_systems [ ^ ],

http://en.wikipedia.org/wiki/Comparison_of_relational_database_management_systems [< a href =http://en.wikipedia.org/wiki/Comparison_of_relational_database_management_systemstarget =_ blanktitle =New Window> ^ ]。



-SA

If you want SQL, yes, certainly. You can consider a good set of decent SQL-based database servers, proprietary or open source:
http://en.wikipedia.org/wiki/List_of_relational_database_management_systems[^],
http://en.wikipedia.org/wiki/Comparison_of_relational_database_management_systems[^].

—SA


这篇关于什么是通过网络访问微软访问数据库的最佳方式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆