我用动态连接数据库用以下代码:
BeforeConnectOuterDataSource
If e.Name = "AA" Then
If Connections.TryConnect(e.ConnectionString) = False Then
Dim strConn As String = ""
Dim flag As Boolean = False
If FileSys.FileExists(e.ProjectPath & "ip.txt") Then
strC & FileSys.ReadAllText(e.ProjectPath & "ip.txt",Encoding.Default) & ";Persist Security Info=False;Jet OLEDB:Database Password=0856474"
If Connections.TryConnect(strConn) = False Then
flag = False
Else
e.ConnectionString = strConn
flag = True
End If
End If
If flag = False Then
Dim dlg As New OpenFileDialog
dlg.Filter= "Access文件|*.mdb"
If dlg.ShowDialog = DialogResult.Ok Then
e.C & dlg.FileName & ";Persist Security Info=False;Jet OLEDB:Database Password=0856474"
FileSys.WriteAllText(e.ProjectPath & "ip.txt", dlg.FileName, False, Encoding.Default)
End If
End If
End If
End If
我想怎样获取项目所连接数据库文件的目录,与压缩代码怎样结合起来?
CompactAccessFile("C:\Data\订单.mdb","123")
[此贴子已经被作者于2017/6/7 20:42:55编辑过]