ad

如何允许多个用户访问/编辑Microsoft Access数据库?-英雄云拓展知识分享

匿名投稿 223 2024-01-22

现在,我立即知道Microsoft Access不是访问它的多个用户的理想客户端,但这是我现在唯一具有的客户。我已建立了一个小程序作为一种库存管理系统。当前有3个用户将定期和同时使用它。我遇到的一个问题是,有时数据库将没法访问,并且会出现一个毛病,说明文件已在“ so so so”用户中使用。另外一个问题是,我时不时会遇到类似的毛病,即“数据库已由用户将数据库放置在机器上,以避免其打开或锁定”。我正在使用下面的行经过ACE OLEDB连接连接到数据库

con.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=P:\Tool & Cutter Grinding\Tool Cutter Database.accdb;Persist Security Info = False"

如何允许多个用户访问/编辑Microsoft Access数据库?-英雄云拓展知识分享

我还更改了实际访问数据库中的一些设置,例如:

  1. 启用所有宏
  2. 将数据库所在的文件夹添加到受信任的位置列表中
  3. 确认数据库设置为在同享模式下打开

我不知道我错过了一些很小的东西还是需要更改的设置,但是到至今为止为止,问题依然存在。

以下是我如何使用数据库的示例。我正在使用基于字符串的SQL命令,但不太熟习 DataSet/DataTable/ETC。物品,所以我可能会做些毛病的事情。

 'close connection from any previous session

con.Close()

'clear dataset so as not to Append data

ds.Clear()

'Select SQL query that selects ALL records from a table

Dim str As String = "SELECT * FROM " & "[" & table & "]" & ""

con.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=P:\Tool & Cutter Grinding\Tool Cutter Database.accdb;Persist Security Info = False"

'use try catch statement to open the connection

Try

con.Open()

Catch ex As Exception

MsgBox(Convert.ToString(ex))

End Try

'use try catch statement to add a table (dt) to the dataset (ds) in order to store values

Try

ds.Tables.Add(dt)

Catch ex As Exception

End Try

'create new dataadapter object using the sql string from above and the connection created above

da = New OleDbDataAdapter(str, con)

'create new command builder in order to excecute the SELECT SQL statement using the dataadapter created (da)

'specify prefix and suffix for cb

Dim cb = New OleDbCommandBuilder(da) With {

.QuotePrefix = "[",

.QuoteSuffix = "]"

}

'use try catch statement to fill the datatable (dt) using the dataadapter (da)

Try

da.Fill(dt)

Catch ex As Exception

MsgBox(Convert.ToString(ex))

End Try

'set the datasource of the datagridview to the datatable

dgv.DataSource = dt.DefaultView

'close the connection to the database

con.Close()

看答案

转到您的后端访问DB文件。文件>选项>客户设置。对您的用例,没有锁可以很好,但是如果需要的话,编辑的记录设置也将起作用


🚀🌟 点击注册 免费试用超级应用平台-英雄云企业级hpaPAAS 🌟🚀 😃👉🌐

免责声明:

本网址(www.yingxiongyun.com)发布的材料主要源于独立创作和网友匿名投稿。此处提供的所有信息仅供参考之用。我们致力于提供准确且可信的信息,但不对材料的完整性或真实性作出任何保证。用户应自行验证相关信息的正确性,并对其决策承担全部责任。对于由于信息的错误、不准确或遗漏所造成的任何损失,本网址不承担任何法律责任。本网站所展示的所有内容,如文字、图像、标志、音频、视频、软件和程序等的版权均属于原创作者。如果任何组织或个人认为网站内容可能侵犯其知识产权,或包含不准确之处,请即刻联系我们进行相应处理。

标签:vb.net 视觉工作室
上一篇:SASS地图输出-英雄云拓展知识分享
下一篇:VBA宏找不到ActiveCell的最后一个使用的单元格-英雄云拓展知识分享
相关文章

 发表评论

暂时没有评论,来抢沙发吧~

×