我有一个需要导入到我的 Access 数据库中的 Excel 表。工作表如下所示:
日期 接收 面额 项目 N° 数量 RECUE 06/01/2010 DVD-欲望都市 PCR-PA21550167 5 06/01/2010 DVD-阿凡达娜蒂 2 PCR-PA21550209 10
然后我使用 adodb 将此文件传输到数据库中:
Dim rs2 As New ADODB.Recordset
Dim cnn2 As New ADODB.Connection
Dim cmd2 As New ADODB.Command
Dim intField As Integer
Dim strFile As String
strFile = fncOpenFile
If strFile = "" Then Exit Sub
With cnn2
.Provider = "Microsoft.Jet.OLEDB.4.0"
.ConnectionString = "Data Source=" & strFile& "; " & "Extended Properties=Excel 8.0"
.Open
End With
Set cmd2.ActiveConnection = cnn2
cmd2.CommandType = adCmdText
cmd2.CommandText = "SELECT * FROM [PCR$]"
rs2.CursorLocation = adUseClient
rs2.CursorType = adOpenDynamic
rs2.LockType = adLockOptimistic
rs2.Open cmd2
While Not rs2.EOF
strNaam = rs2.Fields(3).Value
Loop
现在我的问题:某些字段中有文本。字段值应该是item0001
,但据报道它是 NULL
当该字段具有常规数字时,它可以正常工作。
奇怪的是:工作表中还有其他文本字段,它们工作正常。