这个多用户同时修改一条数据报错的问题困扰着我 几个帖子都无法结贴。关于多用户环境,直接使用SQL语句+事务来更新,请问类似连接打开数据库的代码 每个窗体都要用到吗? Dim ZhwgCon As New ADODB.Connection
Dim ZhwgRS As New ADODB.Recordset
ZhwgCon.ConnectionString = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=zhwg;Data Source=user"
ZhwgCon.Open那么 我在编辑窗体里面 上一条 下一条 保存 关闭 这些按钮事件 都要用这样的代码?
Dim ZhwgRS As New ADODB.Recordset
ZhwgCon.ConnectionString = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=zhwg;Data Source=user"
ZhwgCon.Open那么 我在编辑窗体里面 上一条 下一条 保存 关闭 这些按钮事件 都要用这样的代码?
Dim ZhwgRS As New ADODB.Recordset放在"通用"或模块里就不需要每次
public ZhwgCon As New ADODB.Connection
'Dim ZhwgRS As New ADODB.Recordset '这个不用在标准模块
ZhwgCon.ConnectionString = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=zhwg;Data Source=user"
If ZhwgCon.State <> ADODB.ObjectStateEnum.adStateClosed Then ZhwgCon.Close
ZhwgCon.Open
你建一个过程,然后放里面就可以了啊,public定义放到过程外.
Option Explicit
Public ZhwgCon As New ADODB.ConnectionPublic Sub Main()
ZhwgCon.ConnectionString = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=zhwg;Data Source=user"
If ZhwgCon.State <> ADODB.ObjectStateEnum.adStateClosed Then ZhwgCon.Close
ZhwgCon.Open Form1.show
End Sub
看来还得说下,工程属性启动项选择main
ZhwgCon.ConnectionString = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=zhwg;Data Source=user"
If ZhwgCon.State <> ADODB.ObjectStateEnum.adStateClosed Then ZhwgCon.Close
ZhwgCon.Open
End Sub我添加了过程啊 可以工程属性启动项选择main 说没有窗体不行啊
我光在mdi 里面声明和 添加过程 不行。 必须用到的窗体 都要 声明和添加过程是这样吗?
倒是ZhwgRS需要用到的地方定义.
如果还不清楚,建议静下心来看看基础的工程概念.