# Re: 怎样动态设定DataEnvironment 的DataSource?

Posted by 大汉堡 on August 11, 1999 at 03:14:28:

In Reply to: 怎样动态设定DataEnvironment 的DataSource? posted by Fai on August 10, 1999 at 16:48:39:

: 本人有一个DataEnvironment,DataSource="D:\ESU\ESU.mdb",DataEnvironment 裹面有几个Command
: 由于这程式会设在不同的电脑上,因此需要改变不同的Path
: 所以要动态设定DataEnvironment 的DataSource

: 我在form中,写了此行
: ConnStr = "Provider=Microsoft.Jet.OLEDB.3.51;" & "Data Source=" & DbDir & "ESU.mdb"
: DataEnvironment1.Connection1.ConnectionString = ConnStr
: 想动态改变Directory Path 的位置,当一用到Command 的时候
: Error Message is displayed as "[Microsoft][ODBC Driver Manager] Data Source name not found and no default driver specified"
: 请问应怎么办?
不要先设定,于程式执行再做
Private Sub Connection1_WillConnect(ConnectionString As String, Userid As String, Password As String, Options As Long, adStatus As ADODB.EventStatusEnum, ByVal pConnection As ADODB.Connection)
DataEnvironment1.Connection1.Properties("data source") = ConnStr
End Sub

Follow Ups:

- Re: 怎样动态设定DataEnvironment 的DataSource? Fai 10:42:00 8/11/99 (2)
  - Re: 怎样动态设定DataEnvironment 的DataSource? 大汉堡 04:38:38 8/12/99 (1)
    - Re: 我已经试到!谢谢!怎样动态设定DataEnvironment 的DataSource? Fai 12:21:33 8/12/99 (0)