[算表] ADO在某些欄位的中文字無法取回
軟體:Excel
版本:2013
各位板上的大大下午好。承上篇 CopyFrom...當機的問題。
首先感謝Soyoso大大的指導幾本上ADO Open當機的問題已經解決了。
但是我把當資料取回來之後發現品名這個欄位只要有中文字就會變成空白
其他的欄位縱使有中文字也不會有問題。
下方是我的程式碼。
ADO在透過網芳取得資料這一塊好像有問題。本機都可以運作的很好。
============Notice頁面======
Private Sub DueDateCrossing_Click()
Dim MS As String 'SQL command
Dim WBPath As String ' Workbook Path
Dim N As Integer 'To fetch data of N days later, N must smaller than 31
Dim D As Date ' D is refered to Date
Dim TM As Integer ' TM is refered to this month
Dim DueDate As Date 'DueDate is refered to DueDate
Dim DueDateS As String
D = Date
TM = Month(D)
N = 7
DueDate = DateAdd("d", N, D)
DueDateS = "#" & DueDate & "#" 'The symbol "#" is required by date
formate.
WBPath = "D:\desktop\2019生產管制表.xlsx"
MS = "SELECT * From [" & TM & "月$a:q]" & _
" WHERE 預交日期=" & DueDateS
GetData MS, WBPath
End Sub
==================Sub Module=========
Sub GetData(MS As String, WBPath As String)
'This sub is used to fetch data from produciton schedule.
On Error Resume Next
Dim MC As String 'MC is refered to My Connection
Dim MR As ADODB.Recordset 'MR is refered to My Recordset
MC = "Provider=Microsoft.ACE.OLEDB.12.0;" & _
"Data Source=" & WBPath & ";" & _
"Extended Properties=Excel 12.0;"
Set MR = New ADODB.Recordset
MR.Open MS, MC, adOpenStatic, adLockReadOnly
Worksheets("Notice").Range("A2").CopyFromRecordset MR
End Sub
==========================================
原始資料
https://imgur.com/zVUKxAU
ADO取得的資料
https://imgur.com/NuLslBV

懇請高手指導,感謝。
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 114.33.116.8 (臺灣)
※ 文章網址: https://www.ptt.cc/bbs/Office/M.1571206240.A.B31.html
→
10/16 14:42,
6年前
, 1F
10/16 14:42, 1F
→
10/16 14:42,
6年前
, 2F
10/16 14:42, 2F

→
10/16 14:45,
6年前
, 3F
10/16 14:45, 3F
→
10/16 14:45,
6年前
, 4F
10/16 14:45, 4F
→
10/16 14:45,
6年前
, 5F
10/16 14:45, 5F
→
10/16 14:46,
6年前
, 6F
10/16 14:46, 6F
→
10/16 14:49,
6年前
, 7F
10/16 14:49, 7F
→
10/16 14:49,
6年前
, 8F
10/16 14:49, 8F
→
10/16 14:49,
6年前
, 9F
10/16 14:49, 9F
→
10/16 14:49,
6年前
, 10F
10/16 14:49, 10F
→
10/16 14:53,
6年前
, 11F
10/16 14:53, 11F
→
10/16 14:54,
6年前
, 12F
10/16 14:54, 12F
→
10/16 14:55,
6年前
, 13F
10/16 14:55, 13F
→
10/16 14:56,
6年前
, 14F
10/16 14:56, 14F
→
10/16 14:57,
6年前
, 15F
10/16 14:57, 15F
→
10/16 15:10,
6年前
, 16F
10/16 15:10, 16F
→
10/16 15:10,
6年前
, 17F
10/16 15:10, 17F
→
10/16 15:37,
6年前
, 18F
10/16 15:37, 18F
Office 近期熱門文章
PTT數位生活區 即時熱門文章