代码如下:
'If ListView1.SelectedItem.Text <> " " Then
'Dim FileName As String
'Dim a As Long
'conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;Data Source=db1.mdb;Jet OLEDB:Database Password=1234"
'Rs.Open "select * from file1", conn, adOpenKeyset, adLockPessimistic '打开数据库的表
'FileName = ListView1.SelectedItem.Text
'If FileName = "" Then
'Exit Sub
'End If
'End If
'Call ShellExecute(hwnd, "Open", App.Path & "\" & ListView1.SelectedItem.Text, "", App.Path, 1)希望实现的功能:文件在数据库中用超级链接的方式存储,在listview里能够打开文件
'If ListView1.SelectedItem.Text <> " " Then
'Dim FileName As String
'Dim a As Long
'conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;Data Source=db1.mdb;Jet OLEDB:Database Password=1234"
'Rs.Open "select * from file1", conn, adOpenKeyset, adLockPessimistic '打开数据库的表
'FileName = ListView1.SelectedItem.Text
'If FileName = "" Then
'Exit Sub
'End If
'End If
'Call ShellExecute(hwnd, "Open", App.Path & "\" & ListView1.SelectedItem.Text, "", App.Path, 1)希望实现的功能:文件在数据库中用超级链接的方式存储,在listview里能够打开文件
解决方案 »
- 图片转换格式(固定长宽)
- DataGrid控件中被选中行的颜色设置
- 播放Flash时怎么没声音?
- 请教一个查询问题?请各位高手指教!
- 如果我后台使用的是sql server2000的数据库,那么可以打包成为安装文件,在安装以后不用再手动导入数据库文件了吗?谢谢!
- vb有没有向windows rebar这样的控件?
- 谁能告诉我这段代码的意思啊!谢谢
- 请教各位大虾!这个语句怎么写????急急急!!(在线等待)
- 请问有谁知道哪里有“图形交互”工程的源代码?请告知下载地址或发送到下述信箱
- 请问:哪里有crystal Reports报表工具?
- 请问ActiveX document在Internet应用中用的多么?
- 关于循环引用:COM的interface还有高低之说呢?
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
'函数功能:连接指定的数据库
'参数说明:cnnP:数据库连接对象;
' :adoP:数据集存储对象;
' :strPath:数据库路径;
' :strPassword:数据库密码;
'返回说明:True:连接成功 False:连接失败
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Public Function funConnectDataBase(cnnP As ADODB.Connection, adoP As ADODB.Recordset, ByVal strPath As _
String, ByVal strPassword As String) As Boolean
On Error GoTo errFunction
Set cnnP = New ADODB.Connection
Set adoP = New ADODB.Recordset
cnnP.Provider = "Microsoft.Jet.OLEDB.4.0"
cnnP.Open "Data Source = " & strPath & ";jet oledb:database password=" & strPassword
funConnectDataBase = True
Exit Function
errFunction:
funConnectDataBase = False
End Function
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
'函数功能:关闭数据库连接对象和数据文件的关联
'参数说明:cnnP:数据库连接对象;
' :adoP:数据库存储对象;
'返回说明:True:关闭连接成功 False:关闭连接失败
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Public Function funCloseDataBase(cnnP As ADODB.Connection, adoP As ADODB.Recordset) As Boolean
On Error GoTo errFunction
Set adoP = Nothing
Set cnnP = Nothing
funCloseDataBase = True
Exit Function
errFunction:
funCloseDataBase = False
End Function
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
'过程功能:对指定的对象执行指定的SQL语句
'参数说明:cnnP:ADO连接对象
' :adoP:ADO记录集对象
' :strSql:SQL语句
' :bolQueryRecord:是否是查询记录集
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%Public Sub subExcuteSQL(cnnP As ADODB.Connection, adoP As ADODB.Recordset, strSql As String, bolQueryRecord _
As Boolean)
If bolQueryRecord Then '如果是查询记录集
adoP.Open strSql, cnnP, adOpenStatic, adLockBatchOptimistic
Else
cnnP.Execute strSql
End If
End Sub
读的时候用SHELL运行这个字符串,系统就会自动打开它了
示例
FileName = ListView1.SelectedItem.Text
Shell "start.exe " & FileName, vbHide