仍然是压缩mdb文件的问题
使用ado2.5的版本!
如何压缩
参考:
http://www.csdn.net/expert/topic/530/530394.xml?temp=.7059595
一下代码问题在于不支持长文件名,转化以后也不行,请大家给出更好的方法,这个是使用odbc的东西!
代码:
不支持长文件名
Option Explicit
'********************************************************************
Const ODBC_ADD_DSN = 1 ' Add data source
Const ODBC_CONFIG_DSN = 2 ' Configure (edit) data source
Const ODBC_REMOVE_DSN = 3 ' Remove data source
#If Win32 Then
Private Declare Function SQLCONFIGDATASOURCE Lib "odbccp32.dll" Alias "SQLConfigDataSource" _
(ByVal hWndParent&, _
ByVal fRequest%, _
ByVal lpszDriver$, _
ByVal lpszAttributes$) As Boolean
#ElseIf Win16 Then
Private Declare Function SQLCONFIGDATASOURCE Lib "odbcinst.dll" _
(ByVal hWndParent%, _
ByVal fRequest%, _
ByVal lpszDriver$, _
ByVal lpszAttributes$) As Boolean
#End If
Public Sub CompactDb(ByVal strfrom As String, ByVal strto As String)
Dim dbDriver As String
Dim dbAttributes As String
Dim result As Boolean
#If Win32 Then
Let dbDriver = "Microsoft Access Driver (*.mdb)"
#ElseIf Win16 Then
Let dbDriver = "Access Files (*.mdb)"
#End If
Let dbAttributes = "COMPACT_DB=" & strfrom & " " & strto & Chr$(0) _
& "UID=admin" & Chr$(0) _
& "PWD=xxx"
result = SQLCONFIGDATASOURCE(0, ODBC_CONFIG_DSN, dbDriver, dbAttributes)
If (False = result) Then
MsgBox "Establishing DSN failed! Error: " & result
End If
End Sub