这是我目前来自internet
的代码Dim con As New OleDb.OleDbConnection
Dim dbProvider As String
Dim dbSource As String
dbProvider = "PROVIDER=Microsoft.Jet.OLEDB.4.0;"
dbSource = "Data Source = C:\Users\CSI_FOREX\Dropbox\CSI Files\Euel CSI\cctvGmapVBnew\cctvGmapVBnew\database\sample\cctvGmapVbDatabase.mdb"
con.ConnectionString = dbProvider & dbSource
con.Open()
MsgBox("Database is now open")
con.Close()
MsgBox("Database is now Closed")
现在,此代码有效。有什么方法可以缩短它吗?它与我的项目位于同一文件夹中.. \database\sample\myFile
如果我要按原样部署它,我会遇到问题。感谢。
答案 0 :(得分:0)
Imports System.IO
dbSource = "Data Source = " & Path.Combine(Application.StartupPath, "database\sample\cctvGmapVbDatabase.mdb")