vb打开access
答案:3 悬赏:40 手机版
解决时间 2021-12-01 16:38
- 提问者网友:暮烟疏雨之际
- 2021-12-01 00:30
vb打开access
最佳答案
- 五星知识达人网友:woshuo
- 2021-12-01 01:26
修改答案:
哦,dos不支持长路径,那你用这段代码吧
Private Declare Function ShellExecute Lib "shell32.dll" Alias _
"ShellExecuteA" (ByVal hWnd As Long, ByVal lpOperation As String, _
ByVal lpFile As String, ByVal lpParameters As String, _
ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
Const SW_SHOWNORMAL As Long = 1
Const SW_HIDE As Long = 0
'access文件扩展名应该是 MDB 吧?
Private Sub Command1_Click()
Call ShellExecute(Me.hWnd, "Open", "好.mdb", vbNullString, App.Path, SW_SHOWNORMAL)
End Sub
如果你没有生产exe文件,它的默认路径在“C:\Documents and Settings\new”
如果你的“好.mdb”没有在此文件夹中,最好是先生成exe文件再调试。
本程序在xp系统调试成功
哦,dos不支持长路径,那你用这段代码吧
Private Declare Function ShellExecute Lib "shell32.dll" Alias _
"ShellExecuteA" (ByVal hWnd As Long, ByVal lpOperation As String, _
ByVal lpFile As String, ByVal lpParameters As String, _
ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
Const SW_SHOWNORMAL As Long = 1
Const SW_HIDE As Long = 0
'access文件扩展名应该是 MDB 吧?
Private Sub Command1_Click()
Call ShellExecute(Me.hWnd, "Open", "好.mdb", vbNullString, App.Path, SW_SHOWNORMAL)
End Sub
如果你没有生产exe文件,它的默认路径在“C:\Documents and Settings\new”
如果你的“好.mdb”没有在此文件夹中,最好是先生成exe文件再调试。
本程序在xp系统调试成功
全部回答
- 1楼网友:長槍戰八方
- 2021-12-01 03:19
Public Declare Function ShellExecute Lib "shell32.dll" Alias _
"ShellExecuteA" (ByVal hWnd As Long, ByVal lpOperation As String, _
ByVal lpFile As String, ByVal lpParameters As String, _
ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
Const SW_SHOWNORMAL As Long = 1
Const SW_HIDE As Long = 0
'access文件扩展名应该是 MDB 吧?
Private Sub Command1_Click()
Call ShellExecute(Me.hWnd, "Open", "好.mdb", vbNullString, App.Path, SW_SHOWNORMAL)
End Sub
"ShellExecuteA" (ByVal hWnd As Long, ByVal lpOperation As String, _
ByVal lpFile As String, ByVal lpParameters As String, _
ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
Const SW_SHOWNORMAL As Long = 1
Const SW_HIDE As Long = 0
'access文件扩展名应该是 MDB 吧?
Private Sub Command1_Click()
Call ShellExecute(Me.hWnd, "Open", "好.mdb", vbNullString, App.Path, SW_SHOWNORMAL)
End Sub
- 2楼网友:独行浪子会拥风
- 2021-12-01 01:41
你可以通过ado方法或通过adodc 控件将vb与access连接起来
例如:
Public Sub connection()
Public conn As New ADODB.connection
Public rs As New ADODB.Recordset
Dim strSQL As String
Dim str1 As String
Dim str2 As String
str1 = "Provider=Microsoft.Jet.OLEDB.4.0;"
str2 = "Data Source=好.mdb;"
conn.Open str1 & str2
End Sub
例二:
Dim MSAccess As Access.Application
MSAccess.OpenCurrentDatabase (App.Path & "\好.mdb")
Set MSAccess = Nothing
我可以给你发一个VB与access联合开发的案例
例如:
Public Sub connection()
Public conn As New ADODB.connection
Public rs As New ADODB.Recordset
Dim strSQL As String
Dim str1 As String
Dim str2 As String
str1 = "Provider=Microsoft.Jet.OLEDB.4.0;"
str2 = "Data Source=好.mdb;"
conn.Open str1 & str2
End Sub
例二:
Dim MSAccess As Access.Application
MSAccess.OpenCurrentDatabase (App.Path & "\好.mdb")
Set MSAccess = Nothing
我可以给你发一个VB与access联合开发的案例
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯