打开现有的Access数据库 [英] Open existing Access database

查看:94
本文介绍了打开现有的Access数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我有一个名为Sales.Mdb的访问数据库

在vb.net 2005中,我想打开它。我能做什么。

我不知道如何弄清楚Sales.Mdb是否已经打开。

如果是这样,我想打开那个实例。

我想怎么做?

谢谢

Hi
I have an access database called Sales.Mdb
In vb.net 2005, I''d like to open it. Which I can do.
What I can''t figure out is how to figure out if Sales.Mdb is open already.
If so, I want to open that instance.
Any ideas how I would do this?
Thanks

推荐答案



嗯?


''打开它''

你的意思是通过OleDbConnection类访问Jet数据库吗?
http://msdn.microsoft.com/en-us/libr...on(VS.71).aspx

或其他什么?

................


我的猜测是你担心它已经打开了吗?因为

你会遇到并发问题。


我会调查这些方法:

ExecuteNonQuery

ExecuteReader

ExecuteScalar


如果像Jet数据库一样脆弱,你需要学习如何获得

in,并尽可能快地获得OUT ...对于并发性。


我不知道如何知道数据库是打开的。 (<<<<<<<<<<<<<<<&n;             Jet

数据库上的ExecuteReader:

http://sholliday.spaces.live.com/Blog/cns!A68482B9628A842A!176.entry

可下载的代码在C#中。


" SimeonD" < si ***** @ nospam.nospamwrote in message

新闻:哦************** @ TK2MSFTNGP06.phx.gbl ...

Huh?

''open it''

Do you mean access the Jet database via the OleDbConnection class?
http://msdn.microsoft.com/en-us/libr...on(VS.71).aspx
Or something else?

................

My guess is that you''re concerned about "is it already opened" because
you''re getting concurrency issues.

I would investigate these methods:
ExecuteNonQuery
ExecuteReader
ExecuteScalar

With something as fragile as a Jet database, you need to learn how to "get
in, and get OUT...as quick as possible" for concurrency.

I do not know of a way to know the database is "opened" (<<I''m assuming you
mean by the PROGRAM : Microsoft Access ).

You can download a very basic example of using .ExecuteReader on a Jet
database here:
http://sholliday.spaces.live.com/Blog/cns!A68482B9628A842A!176.entry
The downloadable code is in C#.

"SimeonD" <si*****@nospam.nospamwrote in message
news:Oh**************@TK2MSFTNGP06.phx.gbl...



我有一个名为Sales.Mdb的访问数据库

在vb.net 2005中,我会喜欢打开它。我能做什么。

我不知道如何弄清楚Sales.Mdb是否已经打开。

如果是这样,我想打开那个实例。

我想怎么做?

谢谢
Hi
I have an access database called Sales.Mdb
In vb.net 2005, I''d like to open it. Which I can do.
What I can''t figure out is how to figure out if Sales.Mdb is open already.
If so, I want to open that instance.
Any ideas how I would do this?
Thanks



11月17日上午8:04 *,SimeonD < sime ... @nospam.nospamwrote:
On Nov 17, 8:04*am, "SimeonD" <sime...@nospam.nospamwrote:



我有一个名为Sales.Mdb的访问数据库

在vb.net 2005中,我想打开它。我能做什么。

我不知道如何弄清楚Sales.Mdb是否已经打开..

如果是这样,我想打开那个例子。

我想怎么做这个?

谢谢
Hi
I have an access database called Sales.Mdb
In vb.net 2005, I''d like to open it. Which I can do.
What I can''t figure out is how to figure out if Sales.Mdb is open already..
If so, I want to open that instance.
Any ideas how I would do this?
Thanks



我在猜你想要做两件事之一,首先你可能想要使用Process.Start(...)打开文件。
。如果是这样的话,那么我就不知道有什么好的方法可以看出它是否已经开放,而且我不认为b $ b认为这很重要。如果用户想要多个实例并且Access会将它们放在那里,那么你也应该这样做(换句话说,这不是你的问题)。

如果你是打开Access作为自动化任务的一部分

通过Process.Start(...),不要。


其次,如果你想尝试作为

自动化例程的一部分与Access交互,您应该通过ADO.NET这样做。这样做

将解决Access被打开而不是关闭的问题,因为ADO.NET

将无法启动Access。如果您不知道如何做到这一点,那么在Google上搜索一些

应该会提供一些分步说明。


谢谢,


Seth Rowe [MVP]
http:/ /sethrowe.blogspot.com/


我应该更清楚。

以下是我已经拥有的代码。这将在新的实例中打开表单

的访问权限。

我想检查现有Access的原因是停止相同的数据库

多次开通。


Dim oAccess As Access.Application

Dim oForm As Access.Form

Dim stCriteria作为String

Dim sForm As String''要显示的表单名称


''为自动化启动Access的新实例:

oAccess =新的Access.ApplicationClass()


''确保Access可见:

如果不是oAccess.Visible然后oAccess.Visible = True


oAccess.OpenCurrentDatabase(filepath:= Sales_Path,Exclusive:= False)

sForm =" frmSales"

oAccess.DoCmd .OpenForm(sForm,Access.AcFormView.acNormal)

" rowe_newsgroups" < ro ******** @ yahoo.com写了留言

news:dc ********************** ************ @ v5g2000p rm.googlegroups.com ...

11月17日上午8:04,SimeonD < sime ... @nospam.nospamwrote:
I should have been clearer.
Below is the code I have already. This will open the form, in a new instance
of access.
The reason I want to check for existing Access, is to stop the same db being
opened multiple times.

Dim oAccess As Access.Application
Dim oForm As Access.Form
Dim stCriteria As String
Dim sForm As String ''name of form to show

'' Start a new instance of Access for automation:
oAccess = New Access.ApplicationClass()

'' Make sure Access is visible:
If Not oAccess.Visible Then oAccess.Visible = True

oAccess.OpenCurrentDatabase(filepath:=Sales_Path, Exclusive:=False)
sForm = "frmSales"
oAccess.DoCmd.OpenForm(sForm, Access.AcFormView.acNormal)
"rowe_newsgroups" <ro********@yahoo.comwrote in message
news:dc**********************************@v5g2000p rm.googlegroups.com...
On Nov 17, 8:04 am, "SimeonD" <sime...@nospam.nospamwrote:



我有一个名为Sales.Mdb的访问数据库

在vb.net 2005中,我想打开它。我能做什么。

我不知道如何弄清楚Sales.Mdb是否已经打开。

如果是这样,我想打开那个实例。

我想怎么做?

谢谢
Hi
I have an access database called Sales.Mdb
In vb.net 2005, I''d like to open it. Which I can do.
What I can''t figure out is how to figure out if Sales.Mdb is open already.
If so, I want to open that instance.
Any ideas how I would do this?
Thanks



我猜你想要的要做两件事之一,首先你可能想要使用Process.Start(...)打开文件。
。如果是这样的话,那么我就不知道有什么好的方法可以看出它是否已经开放,而且我不认为b $ b认为这很重要。如果用户想要多个实例并且Access会将它们放在那里,那么你也应该这样做(换句话说,这不是你的问题)。

如果你是打开Access作为自动化任务的一部分

通过Process.Start(...),不要。


其次,如果你想尝试作为

自动化例程的一部分与Access交互,您应该通过ADO.NET这样做。这样做

将解决Access被打开而不是关闭的问题,因为ADO.NET

将无法启动Access。如果您不知道如何做到这一点,那么在Google上搜索一些

应该会提供一些分步说明。


谢谢,


Seth Rowe [MVP]
http:/ /sethrowe.blogspot.com/


这篇关于打开现有的Access数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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