excel可以当数据库吗
答案:1 悬赏:30 手机版
解决时间 2021-02-07 23:20
- 提问者网友:雨不眠的下
- 2021-02-07 08:29
excel可以当数据库吗
最佳答案
- 五星知识达人网友:大漠
- 2021-02-07 08:37
可以使用DAO,但是Excel数据库是之允许添加、修改、浏览而不允许删除行的:
Sub TestHDRConnectParameter(blnHDRParam As Boolean)
Dim dbs As Database
Dim rst As Recordset
Dim strHDRParam As String
If blnHDRParam = True Then
strHDRParam = "YES"
Else
strHDRParam = "NO"
End If
' Open the Microsoft Jet sample database.
Set dbs = OpenDatabase("C:\JetBook\Samples\Excel\Products97.xls", _
False, False, "Excel 8.0;HDR=" & strHDRParam & ";")
' Create a Recordset object for the Microsoft Excel Products worksheet.
Set rst = dbs.OpenRecordset("Products$")
' Move to the last record and display the RecordCount property value.
With rst
.MoveLast
MsgBox "There are " & .RecordCount & " records in this worksheet."
.Close
End With
dbs.Close
End Sub
注意:
(1)HDR指定是否将首行作为标题行。
(2)表名字后面要加$符号。
Sub TestHDRConnectParameter(blnHDRParam As Boolean)
Dim dbs As Database
Dim rst As Recordset
Dim strHDRParam As String
If blnHDRParam = True Then
strHDRParam = "YES"
Else
strHDRParam = "NO"
End If
' Open the Microsoft Jet sample database.
Set dbs = OpenDatabase("C:\JetBook\Samples\Excel\Products97.xls", _
False, False, "Excel 8.0;HDR=" & strHDRParam & ";")
' Create a Recordset object for the Microsoft Excel Products worksheet.
Set rst = dbs.OpenRecordset("Products$")
' Move to the last record and display the RecordCount property value.
With rst
.MoveLast
MsgBox "There are " & .RecordCount & " records in this worksheet."
.Close
End With
dbs.Close
End Sub
注意:
(1)HDR指定是否将首行作为标题行。
(2)表名字后面要加$符号。
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯