|
- Function getRecordCount() As Long
- Dim AccessFile As String, Database As String
- Dim StrConn As String, strSql As String
- Dim AdoxCat As Object
- Dim AdoCmd As Object
- Dim AdoConn As Object
- Dim AdoRst As Object
- On Error GoTo Errcheck
-
- AccessFile = ThisWorkbook.Path & "\gkzp.mdb"
- Database = "gkzp"
-
- If Dir(AccessFile) = "" Then
- '检测文件是否存在,不存在则创建数据库
- Set AdoxCat = CreateObject("adox.catalog")
- AdoxCat.Create "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & AccessFile & ";Jet OLEDB:Database Password=695360052;"
- Set AdoConn = AdoxCat.ActiveConnection
- Set AdoCmd = CreateObject("ADODB.Command")
- Set AdoCmd.ActiveConnection = AdoConn
- AdoCmd.CommandText = "CREATE TABLE " & Database & _
- " (报名序号 text(3),报名时间 datetime ,报考类型 text(30),操作员 text(6),姓名 text(8),性别 text(2),出生日期 datetime ,籍贯 text(30),民族 text(10)," & _
- "政治面貌 text(20),健康状况 text(20),参加工作时间 datetime ,最高学历毕业时间 datetime ,移动电话 text(12),固定电话 text(11),身份证号 text(18),电子邮箱 text(20)," & _
- "现工作单位及职务(或家庭住址) text(50),报考职位 text(50),全日制教育 text(50),全日制教育毕业院校及专业 text(50),在职制教育 text(50),在职教育毕业院校及专业 text(50),学习工作简历 text(50),提供材料 text(120),资格审查情况 text(10)"
- AdoCmd.Execute , , 1 'adCmdText
- Set AdoCmd = Nothing
- Set AdoxCat = Nothing
- Set AdoConn = Nothing
- getRecordCount = 1
- Exit Function
- End If
- 'StrConn = "Provider=Microsoft.ACE.OLEDB.12.0;" & "Data Source='" & _
- AccessFile & "';jet oledb:Database Password=695360052"
-
- StrConn = "Provider= Microsoft.Jet.OLEDB.4.0;" & _
- "Data Source='" & AccessFile & "';jet oledb:Database Password=695360052"
- Set AdoConn = CreateObject("ADODB.Connection")
- With AdoConn
- .CursorLocation = 3
- .Mode = 3
- .CommandTimeout = 5
- .connectionTimeout = 5
- .Open StrConn
- End With
- strSql = "select * from " & Database
- Set AdoRst = AdoConn.Execute(strSql)
- getRecordCount = AdoRst.RecordCount + 1
- AdoConn.Close
- Set AdoConn = Nothing
- Exit Function
- Errcheck:
- MsgBox Err.Number & vbNewLine & _
- Err.Description
- End Function
复制代码 |
评分
-
查看全部评分
|